Fix adt
authorGan Shun <ganshun@gmail.com>
Thu, 19 Jan 2017 00:54:14 +0000 (16:54 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 19 Jan 2017 03:10:47 +0000 (22:10 -0500)
Add quotes around GERRIT_TOPIC to correctly handle the case where it's
not defined, and fix parsing for branch name.

Signed-off-by: Gan Shun <ganshun@gmail.com>
Change-Id: Icc3e159b73a4a8371a7c4d096345b7ef72f528d1
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
scripts/git/adt

index 2540d93..f74165d 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright 2016 Google Inc
 
 # Use local branch name as the default topic unless overridden
-GERRIT_TOPIC=`git status | grep "# On branch .*" | cut -f 4 -d " "`
+GERRIT_TOPIC=`git status | grep "branch .*" | rev | cut -f 1 -d " " | rev`
 
 GERRIT_REMOTE=gerrit
 GERRIT_PUSH_COMMAND="git push $GERRIT_REMOTE HEAD:refs/for/master"
@@ -73,7 +73,7 @@ do
        fi
 done
 
-if [ $GERRIT_TOPIC != "" ]
+if [ "$GERRIT_TOPIC" != "" ]
 then
        # Append topic
        GERRIT_PUSH_COMMAND="$GERRIT_PUSH_COMMAND/$GERRIT_TOPIC"