mirror of
https://github.com/jorgebucaran/fisher
synced 2024-10-09 09:36:53 +02:00
Install/Update from a branch. Close #269.
Use fisher [install] PLUGIN:BRANCH_NAME to install from any given branch. The default branch is master. You can use `@' instead of `:' to specify the branch name. If you install a plugin from BRANCH and later remove it, the repository in ~/.cache/fisherman/PLUGIN will remain checked out on BRANCH. To force install from another branch specify a different branch, e.g. `:master'. fisher PLUGIN:BRANCH fisher rm PLUGIN fisher PLUGIN # install PLUGIN from BRANCH # or fisher PLUGIN:master # install PLUGIN from master Updating a plugin always fetches the latest HEAD from the currently checked out branch.
This commit is contained in:
parent
5206351715
commit
272e302262
1 changed files with 37 additions and 16 deletions
53
fisher.fish
53
fisher.fish
|
@ -320,7 +320,7 @@ function $fisher_cmd_name
|
||||||
Restore &$real_path& and try again.
|
Restore &$real_path& and try again.
|
||||||
" "$__fisher_stderr"
|
" "$__fisher_stderr"
|
||||||
else
|
else
|
||||||
__fisher_log info "You can only remove plugins you've installed." "$__fisher_stderr"
|
__fisher_log error "Plugin &$name& is not installed." "$__fisher_stderr"
|
||||||
end
|
end
|
||||||
|
|
||||||
break
|
break
|
||||||
|
@ -465,8 +465,8 @@ function __fisher_plugin_fetch_items
|
||||||
end
|
end
|
||||||
|
|
||||||
for i in $argv
|
for i in $argv
|
||||||
echo "[[[$i]]]" > /dev/stderr
|
|
||||||
set -l names
|
set -l names
|
||||||
|
set -l branch
|
||||||
|
|
||||||
switch "$i"
|
switch "$i"
|
||||||
case \*gist.github.com\*
|
case \*gist.github.com\*
|
||||||
|
@ -480,6 +480,7 @@ function __fisher_plugin_fetch_items
|
||||||
end
|
end
|
||||||
|
|
||||||
case \*
|
case \*
|
||||||
|
printf "%s\n" "$i" | sed 's/[@:]\(.*\)/ \1/' | read i branch
|
||||||
set names (__fisher_plugin_get_names "$i")
|
set names (__fisher_plugin_get_names "$i")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -492,9 +493,9 @@ function __fisher_plugin_fetch_items
|
||||||
set -l src "$fisher_cache/$names[1]"
|
set -l src "$fisher_cache/$names[1]"
|
||||||
|
|
||||||
if test -z "$names[2]"
|
if test -z "$names[2]"
|
||||||
if test -d "$src"
|
if test -d "$src" -a -z "$branch"
|
||||||
if test ! -d "$fisher_config/$names[1]"
|
if test ! -d "$fisher_config/$names[1]"
|
||||||
__fisher_log okay "Fetch &$names[1]&" "$__fisher_stderr"
|
__fisher_log okay "Copy &$names[1]&" "$__fisher_stderr"
|
||||||
end
|
end
|
||||||
|
|
||||||
if test -L "$src"
|
if test -L "$src"
|
||||||
|
@ -503,23 +504,23 @@ function __fisher_plugin_fetch_items
|
||||||
command cp -Rf "$src" "$fisher_config"
|
command cp -Rf "$src" "$fisher_config"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
set jobs $jobs (__fisher_plugin_url_clone_async "$i" "$names[1]")
|
set jobs $jobs (__fisher_plugin_url_clone_async "$i" "$names[1]" "$branch")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if test -d "$src"
|
if test -d "$src" -a -z "$branch"
|
||||||
set -l real_namespace (__fisher_plugin_get_url_info --dirname "$src")
|
set -l real_namespace (__fisher_plugin_get_url_info --dirname "$src")
|
||||||
|
|
||||||
if test "$real_namespace" = "$names[2]"
|
if test "$real_namespace" = "$names[2]"
|
||||||
if test ! -d "$fisher_config/$names[1]"
|
if test ! -d "$fisher_config/$names[1]"
|
||||||
__fisher_log okay "Fetch &$names[1]&" "$__fisher_stderr"
|
__fisher_log okay "Copy &$names[1]&" "$__fisher_stderr"
|
||||||
end
|
end
|
||||||
|
|
||||||
command cp -Rf "$src" "$fisher_config"
|
command cp -Rf "$src" "$fisher_config"
|
||||||
else
|
else
|
||||||
set jobs $jobs (__fisher_plugin_url_clone_async "$i" "$names[1]")
|
set jobs $jobs (__fisher_plugin_url_clone_async "$i" "$names[1]" "$branch")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
set jobs $jobs (__fisher_plugin_url_clone_async "$i" "$names[1]")
|
set jobs $jobs (__fisher_plugin_url_clone_async "$i" "$names[1]" "$branch")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -554,7 +555,7 @@ function __fisher_plugin_fetch_items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function __fisher_plugin_url_clone_async -a url name
|
function __fisher_plugin_url_clone_async -a url name branch
|
||||||
switch "$url"
|
switch "$url"
|
||||||
case https://\*
|
case https://\*
|
||||||
case github.com/\*
|
case github.com/\*
|
||||||
|
@ -573,10 +574,19 @@ function __fisher_plugin_url_clone_async -a url name
|
||||||
|
|
||||||
set -l hm_url (printf "%s\n" "$url" | command sed 's|^https://||')
|
set -l hm_url (printf "%s\n" "$url" | command sed 's|^https://||')
|
||||||
|
|
||||||
|
if test ! -z "$branch"
|
||||||
|
set hm_url "$hm_url ($branch)"
|
||||||
|
set branch -b "$branch"
|
||||||
|
end
|
||||||
|
|
||||||
fish -c "
|
fish -c "
|
||||||
set -lx GIT_ASKPASS /bin/echo
|
set -lx GIT_ASKPASS /bin/echo
|
||||||
|
|
||||||
if command git clone -q --depth 1 '$url' '$fisher_cache/$name' ^ /dev/null
|
if test -d '$fisher_cache/$name'
|
||||||
|
command rm -rf '$fisher_cache/$name'
|
||||||
|
end
|
||||||
|
|
||||||
|
if command git clone $branch -q --depth 1 '$url' '$fisher_cache/$name' ^ /dev/null
|
||||||
printf '$okay""OK""$nc Fetch $okay%s$nc %s\n' '$name' '$hm_url' > $__fisher_stderr
|
printf '$okay""OK""$nc Fetch $okay%s$nc %s\n' '$name' '$hm_url' > $__fisher_stderr
|
||||||
command cp -Rf '$fisher_cache/$name' '$fisher_config'
|
command cp -Rf '$fisher_cache/$name' '$fisher_config'
|
||||||
else
|
else
|
||||||
|
@ -685,21 +695,32 @@ function __fisher_update_path_async -a name path
|
||||||
|
|
||||||
pushd $path
|
pushd $path
|
||||||
|
|
||||||
if not command git fetch -q origin master ^ /dev/null
|
set -l branch (basename (command git symbolic-ref HEAD ^ /dev/null))
|
||||||
|
set -l hm_branch
|
||||||
|
|
||||||
|
if test -z \"\$branch\"
|
||||||
|
set branch master
|
||||||
|
end
|
||||||
|
|
||||||
|
if test \"\$branch\" != master
|
||||||
|
set hm_branch \" (\$branch)\"
|
||||||
|
end
|
||||||
|
|
||||||
|
if not command git fetch -q origin \$branch ^ /dev/null
|
||||||
printf '$error""!""$nc Fetch $error%s$nc\n' '$name' > $__fisher_stderr
|
printf '$error""!""$nc Fetch $error%s$nc\n' '$name' > $__fisher_stderr
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
set -l commits (command git rev-list --left-right --count master..FETCH_HEAD ^ /dev/null | cut -d\t -f2)
|
set -l commits (command git rev-list --left-right --count \$branch..FETCH_HEAD ^ /dev/null | cut -d\t -f2)
|
||||||
|
|
||||||
command git reset -q --hard FETCH_HEAD ^ /dev/null
|
command git reset -q --hard FETCH_HEAD ^ /dev/null
|
||||||
command git clean -qdfx
|
command git clean -qdfx
|
||||||
command cp -Rf '$path/.' '$fisher_cache/$name'
|
command cp -Rf '$path/.' '$fisher_cache/$name'
|
||||||
|
|
||||||
if test -z \"\$commits\" -o \"\$commits\" -eq 0
|
if test -z \"\$commits\" -o \"\$commits\" -eq 0
|
||||||
printf '$okay""OK""$nc Latest $okay%s$nc\n' '$name' > $__fisher_stderr
|
printf '$okay""OK""$nc Latest $okay%s$nc%s\n' '$name' \$hm_branch > $__fisher_stderr
|
||||||
else
|
else
|
||||||
printf '$okay""OK""$nc Pulled $okay%s$nc new commit/s $okay%s$nc\n' \$commits '$name' > $__fisher_stderr
|
printf '$okay""OK""$nc Pulled $okay%s$nc new commit/s $okay%s$nc%s\n' \$commits '$name' \$hm_branch > $__fisher_stderr
|
||||||
end
|
end
|
||||||
|
|
||||||
" > /dev/stderr &
|
" > /dev/stderr &
|
||||||
|
@ -2089,7 +2110,7 @@ function __fisher_help -a cmd number
|
||||||
|
|
||||||
__fisher_log info "Try online: <&github.com/$url&>" "$__fisher_stderr"
|
__fisher_log info "Try online: <&github.com/$url&>" "$__fisher_stderr"
|
||||||
else
|
else
|
||||||
__fisher_log error "You can only check plugins you've installed." "$__fisher_stderr"
|
__fisher_log error "This plugin is not installed." "$__fisher_stderr"
|
||||||
end
|
end
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Reference in a new issue