]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
automation: allow build-test.sh to run in detached HEAD state
authorWei Liu <wei.liu2@citrix.com>
Wed, 27 Feb 2019 17:42:07 +0000 (17:42 +0000)
committerWei Liu <wei.liu2@citrix.com>
Fri, 5 Apr 2019 10:14:57 +0000 (11:14 +0100)
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
automation/scripts/build-test.sh

index c318b65d5a96740a7f1e200411f49b1feee41972..206a4f9a4a4db58c6312d42ec890812a092b17b1 100755 (executable)
@@ -5,6 +5,9 @@
 #
 # The default rune is rather simple. To do a cross-build, please put your usual
 # build rune in a shell script and invoke it with this script.
+#
+# Set NON_SYMBOLIC_REF=1 if you want to use this script in detached HEAD state.
+# This is currently used by automated test system.
 
 if test $# -lt 2 ; then
     echo "Usage:"
@@ -25,10 +28,14 @@ fi
 BASE=$1; shift
 TIP=$1; shift
 
-ORIG_BRANCH=`git symbolic-ref -q --short HEAD`
-if test $? -ne 0; then
-    echo "Detached HEAD, aborted"
-    exit 1
+if [[ "_${NON_SYMBOLIC_REF}" != "_1" ]]; then
+    ORIG=`git symbolic-ref -q --short HEAD`
+    if test $? -ne 0; then
+        echo "Detached HEAD, aborted"
+        exit 1
+    fi
+else
+    ORIG=`git rev-parse HEAD`
 fi
 
 while read num rev; do
@@ -55,7 +62,7 @@ while read num rev; do
 done < <(git rev-list $BASE..$TIP | nl -ba | tac)
 
 echo "Restoring original HEAD"
-git checkout $ORIG_BRANCH
+git checkout $ORIG
 gco_ret=$?
 if test $gco_ret -ne 0; then
     echo "Failed to restore orignal HEAD. Check tree status before doing anything else!"