You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
917 B
34 lines
917 B
#!/usr/bin/env sh
|
|
|
|
# Update the status of the origin
|
|
git remote update origin
|
|
|
|
# Check if we need to update at all
|
|
# Kindly borrowed from http://stackoverflow.com/questions/3258243/git-check-if-pull-needed
|
|
LOCAL=$(git rev-parse @)
|
|
REMOTE=$(git rev-parse @{u})
|
|
BASE=$(git merge-base @ @{u})
|
|
|
|
# All good, no need to update
|
|
if [ $LOCAL = $REMOTE ]; then
|
|
echo "Up-to-date"
|
|
exit 0
|
|
# Time to update to the remote branch
|
|
elif [ $LOCAL = $BASE ]; then
|
|
echo "Need to pull"
|
|
echo 'Updating dotfiles'
|
|
opwd=$PWD
|
|
cd @GIT_DIR@
|
|
git checkout master
|
|
git pull
|
|
git submodule update
|
|
cd $owpd
|
|
# Local changes exist, we need to push these before we can cleanly update
|
|
elif [ $REMOTE = $BASE ]; then
|
|
echo "Local changes, need to push before updating."
|
|
exit 1
|
|
# Divereged branches, this will need a manual cleanup to fix
|
|
else
|
|
echo "Error: Diverged Branches. Resolve Manually"
|
|
exit 1
|
|
fi
|