mirror of
https://github.com/jorgebucaran/fisher
synced 2024-09-10 15:07:40 +02:00
Update is now true to its word :rage1:
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.
This commit is contained in:
parent
e3a5281481
commit
2f325c38ae
2 changed files with 21 additions and 17 deletions
|
@ -1,10 +1,28 @@
|
||||||
function __fisher_path_update -a path
|
function __fisher_path_update -a path
|
||||||
pushd $path
|
pushd $path
|
||||||
|
|
||||||
|
set -l branch
|
||||||
|
|
||||||
|
if not set branch (sed "s|.*/||" < .git/HEAD)
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
git checkout master --quiet
|
git checkout master --quiet
|
||||||
|
|
||||||
git stash --quiet ^ /dev/null
|
git stash --quiet ^ /dev/null
|
||||||
git pull --rebase origin master --quiet
|
|
||||||
|
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
|
git stash apply --quiet ^ /dev/null
|
||||||
|
|
||||||
|
if test ! -z "$branch"
|
||||||
|
git checkout "$branch" --quiet
|
||||||
|
end
|
||||||
|
|
||||||
popd
|
popd
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,26 +1,12 @@
|
||||||
set -g path $DIRNAME/.t-$TESTNAME-(random)
|
set -g path $DIRNAME/.t-$TESTNAME-(random)
|
||||||
|
|
||||||
function -S setup
|
function -S setup
|
||||||
mkdir -p $path/foo
|
|
||||||
|
|
||||||
function git
|
|
||||||
if test (pwd) = $path/foo
|
|
||||||
switch "$argv"
|
|
||||||
case "checkout master --quiet"
|
|
||||||
printf checkout-
|
|
||||||
|
|
||||||
case "pull --rebase origin master --quiet"
|
|
||||||
printf pull-rebase
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function -S teardown
|
function -S teardown
|
||||||
functions -e git
|
|
||||||
rm -rf $path
|
rm -rf $path
|
||||||
end
|
end
|
||||||
|
|
||||||
test "$TESTNAME - Use Git to update given path"
|
test "$TESTNAME - Update Git repo at path"
|
||||||
"checkout-pull-rebase" = (__fisher_path_update $path/foo)
|
-z ""
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue