From 6897ae92d5a9614f4134ec8da57cea4d3e77249f Mon Sep 17 00:00:00 2001 From: Roberto Aguilar Date: Fri, 8 Mar 2013 11:18:14 -0800 Subject: [PATCH] Properly refresh branches. Just calling `git reset --hard` on a branch name doesn't pull in upstream changes. --- bootstrap-salt.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 6e0c059..31f23ea 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -730,7 +730,17 @@ __git_clone_and_checkout() { if [ -d $SALT_GIT_CHECKOUT_DIR ]; then cd $SALT_GIT_CHECKOUT_DIR git fetch - git reset --hard $GIT_REV + git checkout $GIT_REV + + # Just calling `git reset --hard $GIT_REV` on a branch name that has + # already been checked out will not update that branch to the upstream + # HEAD; instead it will simply reset to itself. Check the ref to see + # if it is a branch name, check out the branch, and pull in the + # changes. + git branch -a | grep -q ${GIT_REV} + if [ "$?" == "0" ]; then + git pull --rebase + fi; else git clone https://github.com/saltstack/salt.git salt cd $SALT_GIT_CHECKOUT_DIR