mirror of
https://github.com/jorgebucaran/fisher
synced 2024-11-09 07:10:27 +00:00
d360eb0b99
The update mechanism updates master only. If you are working in branch foo, the branch name is saved and restored later. First attempt a naive git pull --rebase origin master, and if that fails, abort the rebase, fetch origin master, reset to head and clean directory.
29 lines
567 B
Fish
29 lines
567 B
Fish
function __fisher_path_update -a path
|
|
pushd $path
|
|
|
|
set -l branch
|
|
|
|
if not set branch (sed "s|.*/||" < .git/HEAD)
|
|
return 1
|
|
end
|
|
|
|
git checkout master --quiet
|
|
|
|
git stash --quiet ^ /dev/null
|
|
|
|
if not git pull --rebase origin master --quiet ^ /dev/null
|
|
git rebase --abort
|
|
git fetch origin master --quiet
|
|
git reset --hard FETCH_HEAD --quiet
|
|
git clean -d --force --quiet
|
|
end
|
|
|
|
git stash apply --quiet ^ /dev/null
|
|
|
|
if test ! -z "$branch"
|
|
git checkout "$branch" --quiet
|
|
end
|
|
|
|
popd
|
|
end
|