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 diff --git a/.deploy/src/checkout.sh b/.deploy/src/checkout.sh index aa3a3e91..a23c2667 100755 --- a/.deploy/src/checkout.sh +++ b/.deploy/src/checkout.sh @@ -1,12 +1,21 @@ #!/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 +#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 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 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 -