From 6897ae92d5a9614f4134ec8da57cea4d3e77249f Mon Sep 17 00:00:00 2001 From: Roberto Aguilar Date: Fri, 8 Mar 2013 11:18:14 -0800 Subject: [PATCH 1/5] 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 From a042cf9575042f048851fb45d3700ce86c127d8f Mon Sep 17 00:00:00 2001 From: Roberto Aguilar Date: Fri, 8 Mar 2013 11:38:48 -0800 Subject: [PATCH 2/5] Updated status test to be cross-shell compatible. --- bootstrap-salt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 31f23ea..53ca006 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -738,7 +738,7 @@ __git_clone_and_checkout() { # 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 + if [ $? -eq 0 ]; then git pull --rebase fi; else From 654dabcf7dd9e072428a50f27bf0da187feba404 Mon Sep 17 00:00:00 2001 From: Roberto Aguilar Date: Fri, 8 Mar 2013 12:09:43 -0800 Subject: [PATCH 3/5] Disable exiting immediately for branch check. The failing grep will cause the entire script to exit without disabling immediate exiting. --- bootstrap-salt.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 53ca006..1ee88df 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -737,8 +737,11 @@ __git_clone_and_checkout() { # 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. + set +e git branch -a | grep -q ${GIT_REV} - if [ $? -eq 0 ]; then + status=$? + set -e + if [ $status -eq 0 ]; then git pull --rebase fi; else From 637d180f0d3bda492d010d37cfcc6bccfe1da8f6 Mon Sep 17 00:00:00 2001 From: Roberto Aguilar Date: Fri, 8 Mar 2013 12:12:01 -0800 Subject: [PATCH 4/5] Moved tag fetching. In case $GIT_REV is a tag that hasn't been fetched yet. --- bootstrap-salt.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 1ee88df..89a0a5c 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -730,6 +730,7 @@ __git_clone_and_checkout() { if [ -d $SALT_GIT_CHECKOUT_DIR ]; then cd $SALT_GIT_CHECKOUT_DIR git fetch + git fetch --tags git checkout $GIT_REV # Just calling `git reset --hard $GIT_REV` on a branch name that has @@ -749,8 +750,6 @@ __git_clone_and_checkout() { cd $SALT_GIT_CHECKOUT_DIR git checkout $GIT_REV fi - # Tags are needed because of salt's versioning, also fetch that - git fetch --tags } From b1cd89865477dbfda53bc640cfbf326950af8e3b Mon Sep 17 00:00:00 2001 From: Roberto Aguilar Date: Fri, 8 Mar 2013 12:14:20 -0800 Subject: [PATCH 5/5] Reimplemented git reset --hard. This will make sure the working copy isn't dirty. --- bootstrap-salt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 89a0a5c..37c8709 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -731,7 +731,7 @@ __git_clone_and_checkout() { cd $SALT_GIT_CHECKOUT_DIR git fetch git fetch --tags - git checkout $GIT_REV + git reset --hard $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