From 460d809b1bbf0620c95a24f6c08c085eac6f7aff Mon Sep 17 00:00:00 2001 From: Joseph Heffernan Date: Wed, 27 Jun 2012 11:03:20 -0400 Subject: [PATCH 1/4] checkout.sh now recognizes whether it is in detatched head state. It looks for a ':' in .git/HEAD. If it is found, it is a branch. If it is not found, the deployment is in detacthed head state. --- .deploy/src/checkout.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.deploy/src/checkout.sh b/.deploy/src/checkout.sh index aa3a3e91..bc1bf013 100755 --- a/.deploy/src/checkout.sh +++ b/.deploy/src/checkout.sh @@ -5,8 +5,17 @@ mcRoot=`pwd` mkdir -p .local +#Check if in detached head state +headContent=`cat .git/HEAD` +colonLoc=`expr index "$headContent" :` + #Identify Current Version -cat .git/`cat .git/HEAD | awk '{print $NF'}` > .local/CurrentVersionSHA +if [ $colonLoc -eq 0 ] +then + cat .git/HEAD > .local/CurrentVersionSHA +else + cat .git/`cat .git/HEAD | awk '{print $NF'}` > .local/CurrentVersionSHA +fi #spm8Batch Localizations if [ -d .local/spm8Batch ]; then @@ -26,4 +35,4 @@ if [ -f .local/deployment ]; then #Only run this if in a deployment -e "s:%\[DEVmcRoot\]:$mcRoot:" \ $file done -fi \ No newline at end of file +fi From 934226c3ad06ce7c0b3c3e4c58c0fd33cc6e0ccd Mon Sep 17 00:00:00 2001 From: Joseph Heffernan Date: Thu, 28 Jun 2012 11:23:08 -0400 Subject: [PATCH 2/4] Checkout HEAD immediately after setup_deployment.sh and setup_developer.sh to create CurrentVersionSHA in .local --- .deploy/setup_deployment.sh | 5 ++++- .deploy/setup_developer.sh | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.deploy/setup_deployment.sh b/.deploy/setup_deployment.sh index 7e225cd2..4229bdaf 100755 --- a/.deploy/setup_deployment.sh +++ b/.deploy/setup_deployment.sh @@ -20,4 +20,7 @@ touch $thisdir/../.local/deployment echo public > $thisdir/../.local/branch #Make keyfiles -ssh-keygen -f $thisdir/../.local/deploy -N "" \ No newline at end of file +ssh-keygen -f $thisdir/../.local/deploy -N "" + +#Do a checkout to create CurrentVersionSHA +git checkout HEAD diff --git a/.deploy/setup_developer.sh b/.deploy/setup_developer.sh index f26a1501..05754ff7 100755 --- a/.deploy/setup_developer.sh +++ b/.deploy/setup_developer.sh @@ -3,4 +3,7 @@ thisdir=`dirname $0` #Copy hooks -cp $thisdir/src/post-checkout $thisdir/../.git/hooks \ No newline at end of file +cp $thisdir/src/post-checkout $thisdir/../.git/hooks + +#Do a checkout to create CurrentVersionSHA +git checkout HEAD From 44a8b9f05078b8eaa5e8d901b1e932841a9c12de Mon Sep 17 00:00:00 2001 From: Daniel A Kessler Date: Tue, 3 Jul 2012 09:57:54 -0400 Subject: [PATCH 3/4] added comments to checkout script and hook to clarify usage of pwd to figure out mcRoot --- .deploy/src/checkout.sh | 2 +- .deploy/src/post-checkout | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.deploy/src/checkout.sh b/.deploy/src/checkout.sh index bc1bf013..a23c2667 100755 --- a/.deploy/src/checkout.sh +++ b/.deploy/src/checkout.sh @@ -1,7 +1,7 @@ #!/bin/sh #Grab Current Root -mcRoot=`pwd` +mcRoot=`pwd` #Since this is called from post-checkout hook, working directory will be top of work tree unless changed in hook mkdir -p .local diff --git a/.deploy/src/post-checkout b/.deploy/src/post-checkout index 05474cc7..54d2e3cd 100755 --- a/.deploy/src/post-checkout +++ b/.deploy/src/post-checkout @@ -5,3 +5,7 @@ if [ -f .deploy/src/checkout.sh ]; then .deploy/src/checkout.sh fi + +# Note - Be careful not to change working directory at all in this hook, +# since the called script, checkout.sh, depends on `pwd` to figure out the +# top of the git work tree From b247dc5e5ff4758b61e908edf5a31ed3ab0829c4 Mon Sep 17 00:00:00 2001 From: Daniel A Kessler Date: Tue, 3 Jul 2012 09:58:55 -0400 Subject: [PATCH 4/4] removed unused origdir variable, and cleaned up whitespace at end --- .deploy/src/self_update.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/.deploy/src/self_update.sh b/.deploy/src/self_update.sh index 9d067e99..e615a170 100755 --- a/.deploy/src/self_update.sh +++ b/.deploy/src/self_update.sh @@ -4,7 +4,6 @@ thisdir=`dirname $0` #Directory that contains this script -origdir=`pwd` #working directory from whence this script was called cd $thisdir harddir=`pwd` @@ -18,4 +17,3 @@ git reset HEAD --hard git pull github/universe $branch:$branch git checkout $branch -