From eeec0206285e200f34b6005459c4d79a588e7f1d Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 18:42:11 -0700 Subject: [PATCH 1/6] another attempt at reclone which preserves existing git object dir --- stack.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/stack.sh b/stack.sh index 18206cd..74cb383 100755 --- a/stack.sh +++ b/stack.sh @@ -302,20 +302,27 @@ sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*` # be owned by the installation user, we create the directory and change the # ownership to the proper user. function git_clone { - # if there is an existing checkout, move it out of the way - if [[ "$RECLONE" == "yes" ]]; then - # FIXME(ja): if we were smarter we could speed up RECLONE by - # using the old git repo as the basis of our new clone... - if [ -d $2 ]; then - mv $2 /tmp/stack.`date +%s` - fi - fi + # do a full clone only if the directory doesn't exist if [ ! -d $2 ]; then git clone $1 $2 cd $2 # This checkout syntax works for both branches and tags git checkout $3 + elif [[ "$RECLONE" == "yes" ]]; then + # if it does exist then simulate what clone does if asked to RECLONE + cd $2 + # set the url to pull from and fetch + git remote set-url origin $1 + git fetch origin + # if we don't delete the local content, then our system has pyc files + # from the previous branch leading to breakage (due to the py files + # having older timestamps than our pyc, so python thinks the pyc files + # are correct using them) + rm -rf * + git checkout -f origin/$3 + git branch -D $3 + git checkout -b $3 fi } From 917c66584f9c4d596fdf651330e48cd5219a4436 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 18:47:06 -0700 Subject: [PATCH 2/6] use variable names for git_clone function --- stack.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/stack.sh b/stack.sh index 74cb383..ed5dc36 100755 --- a/stack.sh +++ b/stack.sh @@ -303,26 +303,31 @@ sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*` # ownership to the proper user. function git_clone { + GIT_REMOTE=$1 + GIT_DEST=$2 + GIT_BRANCH=$3 + # do a full clone only if the directory doesn't exist - if [ ! -d $2 ]; then - git clone $1 $2 + if [ ! -d $GIT_DEST ]; then + git clone $GIT_REMOTE $GIT_DEST cd $2 # This checkout syntax works for both branches and tags - git checkout $3 + git checkout $GIT_BRANCH elif [[ "$RECLONE" == "yes" ]]; then # if it does exist then simulate what clone does if asked to RECLONE - cd $2 + cd $GIT_BRANCH # set the url to pull from and fetch - git remote set-url origin $1 + git remote set-url origin $GIT_REMOTE git fetch origin # if we don't delete the local content, then our system has pyc files # from the previous branch leading to breakage (due to the py files # having older timestamps than our pyc, so python thinks the pyc files # are correct using them) rm -rf * - git checkout -f origin/$3 - git branch -D $3 - git checkout -b $3 + git checkout -f origin/$GIT_BRANCH + # a local branch might not exist for $3 + git branch -D $GIT_BRANCH || true + git checkout -b $GIT_BRANCH fi } From b9b3ad49a6fc318b51c3746036721918924b523e Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 18:52:13 -0700 Subject: [PATCH 3/6] some of the files are owned by root --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index ed5dc36..8dbb9e9 100755 --- a/stack.sh +++ b/stack.sh @@ -323,7 +323,7 @@ function git_clone { # from the previous branch leading to breakage (due to the py files # having older timestamps than our pyc, so python thinks the pyc files # are correct using them) - rm -rf * + sudo rm -rf * git checkout -f origin/$GIT_BRANCH # a local branch might not exist for $3 git branch -D $GIT_BRANCH || true From 480644bd7461f514f66b41e87ff727c6d86f7fdb Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 18:52:58 -0700 Subject: [PATCH 4/6] error in conversion --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 8dbb9e9..e3f8a94 100755 --- a/stack.sh +++ b/stack.sh @@ -315,7 +315,7 @@ function git_clone { git checkout $GIT_BRANCH elif [[ "$RECLONE" == "yes" ]]; then # if it does exist then simulate what clone does if asked to RECLONE - cd $GIT_BRANCH + cd $GIT_DEST # set the url to pull from and fetch git remote set-url origin $GIT_REMOTE git fetch origin From 9fef844fd9adf0d1a2a68890d5b4d92244f95874 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 19:06:46 -0700 Subject: [PATCH 5/6] use git clean - thanks lundy --- stack.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/stack.sh b/stack.sh index e3f8a94..4b73102 100755 --- a/stack.sh +++ b/stack.sh @@ -319,11 +319,10 @@ function git_clone { # set the url to pull from and fetch git remote set-url origin $GIT_REMOTE git fetch origin - # if we don't delete the local content, then our system has pyc files - # from the previous branch leading to breakage (due to the py files - # having older timestamps than our pyc, so python thinks the pyc files - # are correct using them) - sudo rm -rf * + # remove the existing ignored files (like pyc) as they cause breakage + # (due to the py files having older timestamps than our pyc, so python + # thinks the pyc files are correct using them) + sudo git clean -f -d git checkout -f origin/$GIT_BRANCH # a local branch might not exist for $3 git branch -D $GIT_BRANCH || true From e09a6e4a82debdc5d8d06b0b74312d1266208b76 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 19:09:52 -0700 Subject: [PATCH 6/6] update comment --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 4b73102..6c7dcdf 100755 --- a/stack.sh +++ b/stack.sh @@ -324,7 +324,7 @@ function git_clone { # thinks the pyc files are correct using them) sudo git clean -f -d git checkout -f origin/$GIT_BRANCH - # a local branch might not exist for $3 + # a local branch might not exist git branch -D $GIT_BRANCH || true git checkout -b $GIT_BRANCH fi