]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1042] prepare-commit-msg updated
authorTomek Mrugalski <tomasz@isc.org>
Fri, 13 Dec 2019 16:51:52 +0000 (17:51 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Fri, 13 Dec 2019 17:38:25 +0000 (18:38 +0100)
tools/git-hooks/prepare-commit-msg

index 13bbe84a724be84c42523cf60de8a6a944af0da6..23d6f18195a65802cccf317a67e5d8e741a34a6f 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 BRANCH=`git branch | grep '^\*' | cut -b3-`
+ISSUE=`git branch | grep -o '^\* [0-9]*' | cut -b3-`
 
 if test "$BRANCH" == "master"; then
     echo "ERROR: You are on branch $BRANCH"
@@ -9,7 +10,11 @@ if test "$BRANCH" == "master"; then
     exit 1
 fi
 
-BRANCH_NUMBER=`git branch | grep -o '^\* [0-9]*' | cut -b3-`
-/bin/echo -n "[#$BRANCH_NUMBER] " > "$1.msg"
+if [ -n "$ISSUE" ]; then
+    /bin/echo -n "[#$ISSUE] " > "$1.msg"
+else
+    /bin/echo -n "[$BRANCH] " > "$1.msg"
+fi
+
 cat "$1" >> "$1.msg"
 mv "$1.msg" "$1"