mirror of
https://github.com/jorgebucaran/fisher
synced 2024-10-09 09:36:53 +02:00
Refactor repository fetch logic
This commit is contained in:
parent
daddbadb79
commit
475505312c
2 changed files with 10 additions and 9 deletions
|
@ -29,7 +29,7 @@ Install plugins using the `install` command followed by the path to the reposito
|
||||||
fisher install jorgebucaran/nvm.fish
|
fisher install jorgebucaran/nvm.fish
|
||||||
```
|
```
|
||||||
|
|
||||||
> To install a plugin from GitLab, prefix the repository with `gitlab.com/`.
|
> To install a plugin from GitLab, prefix the name with `gitlab.com/`.
|
||||||
|
|
||||||
To get a specific version of a plugin add an `@` symbol after the plugin name followed by a tag, branch, or [commit](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefcommit-ishacommit-ishalsocommittish).
|
To get a specific version of a plugin add an `@` symbol after the plugin name followed by a tag, branch, or [commit](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefcommit-ishacommit-ishalsocommittish).
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
set --local pid_list
|
set --local pid_list
|
||||||
set --local source_plugins
|
set --local source_plugins
|
||||||
set --local fetch_plugins $update_plugins $install_plugins
|
set --local fetch_plugins $update_plugins $install_plugins
|
||||||
|
@ -87,24 +88,24 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"
|
||||||
command cp -Rf $plugin/* $source
|
command cp -Rf $plugin/* $source
|
||||||
else
|
else
|
||||||
set temp (command mktemp -d)
|
set temp (command mktemp -d)
|
||||||
set name (string split \@ $plugin) || set name[2] HEAD
|
set repo (string split -- \@ $plugin) || set repo[2] HEAD
|
||||||
set url https://api.github.com/repos/\$name[1]/tarball/\$name[2]
|
|
||||||
set header 'Accept: application/vnd.github.v3+json'
|
|
||||||
|
|
||||||
if string match -q 'gitlab.com/*' \$name[1]
|
if set path (string replace --regex -- '^(https://)?gitlab.com/' '' \$repo[1])
|
||||||
set bare (string replace 'gitlab.com/' '' \$name[1])
|
set name (string split -- / \$path)[-1]
|
||||||
set repo (string split '/' \$bare)
|
set url https://gitlab.com/\$path/-/archive/\$repo[2]/\$name-\$repo[2].tar.gz
|
||||||
set url https://gitlab.com/{\$bare}/-/archive/{\$name[2]}/{\$repo[2]}-{\$name[2]}.tar.gz
|
else
|
||||||
|
set url https://api.github.com/repos/\$repo[1]/tarball/\$repo[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
echo Fetching (set_color --underline)\$url(set_color normal)
|
echo Fetching (set_color --underline)\$url(set_color normal)
|
||||||
|
|
||||||
if curl --silent -L -H \$header \$url | tar -xzC \$temp -f - 2>/dev/null
|
if curl --silent -L \$url | tar -xzC \$temp -f - 2>/dev/null
|
||||||
command cp -Rf \$temp/*/* $source
|
command cp -Rf \$temp/*/* $source
|
||||||
else
|
else
|
||||||
echo fisher: Invalid plugin name or host unavailable: \\\"$plugin\\\" >&2
|
echo fisher: Invalid plugin name or host unavailable: \\\"$plugin\\\" >&2
|
||||||
command rm -rf $source
|
command rm -rf $source
|
||||||
end
|
end
|
||||||
|
|
||||||
command rm -rf \$temp
|
command rm -rf \$temp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue