mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-02-15 19:42:49 +08:00
![Stephen M. Coakley](/assets/img/avatar_default.png)
Replace package database with independently installed package repositories - Add support for fetching and installing from package repositories containing package URLs and metadata - Support multiple package repository sources - Add new repo command - Remove submit command - Enhance describe and search commands - Fix and improve help text for new and adjusted commands - Fix bundle install exit status - Refer to plugins as "plugins" instead of the general term "packages" - Code clarity improvements - Put plugin/theme distinction into package metadata
63 lines
1.3 KiB
Fish
63 lines
1.3 KiB
Fish
function omf.index.update -d 'Update package indexes'
|
|
# Only update if the index is missing.
|
|
if contains -- --if-missing $argv
|
|
set -l paths (omf.index.path)/*
|
|
|
|
if set -q paths[1]
|
|
return 0
|
|
end
|
|
end
|
|
|
|
# Find repository lists.
|
|
for list in {$OMF_PATH,$OMF_CONFIG}/repositories
|
|
test -f $list
|
|
and set lists $lists $list
|
|
end
|
|
|
|
# Read the configured repositories from the lists.
|
|
if set -q lists[1]
|
|
set repositories (command awk '
|
|
{
|
|
dir = $1 "_" $2;
|
|
gsub(/[ \/:@]/, "_", dir);
|
|
if (!visited[dir]++) {
|
|
print $1 "\n" $2 "\n" dir;
|
|
}
|
|
}
|
|
' $lists)
|
|
end
|
|
|
|
# Update repositories.
|
|
while set -q repositories[1]
|
|
set -l url $repositories[1]
|
|
set -l branch $repositories[2]
|
|
set -l path (omf.index.path)/$repositories[3]
|
|
set valid_paths $valid_paths $path
|
|
|
|
echo -n "Updating $url $branch... "
|
|
if begin
|
|
if not test -d $path
|
|
command git clone --quiet --depth 1 --branch $branch $url $path
|
|
else
|
|
command git -C $path pull --quiet
|
|
end
|
|
end
|
|
echo "Done!"
|
|
else
|
|
echo "Error"
|
|
return 1
|
|
end
|
|
|
|
set -e repositories[1..3]
|
|
end
|
|
|
|
# Remove repositories not in the lists.
|
|
for path in (omf.index.path)/*
|
|
if not contains -- $path $valid_paths
|
|
command rm -rf $path
|
|
end
|
|
end
|
|
|
|
return 0
|
|
end
|