Commit af49d6f1 authored by Bruno Pinto's avatar Bruno Pinto
parent 2a0e5ba7
......@@ -41,7 +41,7 @@ function omf.install -a type_flag name_or_url
if test -e $OMF_PATH/$target
echo (omf::dim)"Updating $name_or_url $install_type..."(omf::off)
pushd $OMF_PATH/$target
omf.util_sync "origin" >/dev/null ^&1
omf.repo.pull
popd
echo (omf::em)"✔ $name_or_url $install_type up to date."(omf::off)
else
......
function omf.repo.pull
set initial_branch (command git symbolic-ref -q --short HEAD); or return $OMF_UNKNOWN_ERR
set initial_revision (command git rev-parse -q --verify HEAD); or return $OMF_UNKNOWN_ERR
if not command git diff --quiet
echo (omf::em)"Stashing your changes:"(omf::off)
command git status --short --untracked-files
command git stash save --include-untracked --quiet
set stashed true
end
if test "$initial_branch" != master
command git checkout master --quiet
end
# the refspec ensures that 'origin/master' gets updated
command git pull --rebase --quiet origin "refs/heads/master:refs/remotes/origin/master"
if test $status -eq 2 #SIGINT
command git checkout $initial_branch
command git reset --hard $initial_revision
test "$stashed" = true; and command git stash pop
end
if test "$initial_branch" != master
command git checkout $initial_branch --quiet
end
if test "$stashed" = true
command git stash pop --quiet
echo (omf::em)"Restored your changes:"(omf::off)
command git status --short --untracked-files
end
end
......@@ -10,7 +10,7 @@ function omf.update
if git pull --rebase $repo master >/dev/null ^&1
git stash apply >/dev/null ^&1
else
omf.util_sync "origin"
omf.repo.sync
end
end
end
function omf.util_sync -a remote
set -l repo $remote
set -q argv[1]; and set repo $argv[1]
git fetch origin master
git reset --hard FETCH_HEAD
git clean -df
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment