Commit 61f71f3c authored by Bruno Pinto's avatar Bruno Pinto Committed by Derek Stavis

Replace `omf.update` with `omf.repo.pull`

- Pull repository from origin unless upstream exist.
parent 890104ab
function omf.repo.pull
if test (command git config --get remote.upstream.url)
set repository upstream
else
set repository origin
end
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
......@@ -14,8 +20,8 @@ function omf.repo.pull
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"
# the refspec ensures that '$repository/master' gets updated
command git pull --rebase --quiet $repository "refs/heads/master:refs/remotes/$repository/master"
if test $status -eq 2 #SIGINT
command git checkout $initial_branch
command git reset --hard $initial_revision
......@@ -32,4 +38,6 @@ function omf.repo.pull
echo (omf::em)"Restored your changes:"(omf::off)
command git status --short --untracked-files
end
return 0
end
function omf.update
set -l repo "upstream"
test -z (git config --get remote.upstream.url)
and set -l repo "origin"
if git diff-index --quiet HEAD -- >/dev/null ^&1
git pull $repo master >/dev/null ^&1
else
git stash >/dev/null ^&1
if git pull --rebase $repo master >/dev/null ^&1
git stash apply >/dev/null ^&1
else
omf.repo.sync
end
end
end
......@@ -125,7 +125,7 @@ function omf -d "Oh My Fish"
case "u" "up" "upd" "update"
pushd $OMF_PATH
echo (omf::em)"Updating Oh My Fish..."(omf::off)
if omf.update
if omf.repo.pull
echo (omf::em)"Oh My Fish is up to date."(omf::off)
else
echo (omf::err)"Oh My Fish failed to update."(omf::off)
......
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