From 93e4724c6ac4a7e7a7788c7f7ec055ed555e3e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Wed, 17 May 2023 17:33:01 +0200 Subject: [PATCH] #912: catch error for unrecognized branch names that broke the post-checkout hook --- .husky/post-checkout | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.husky/post-checkout b/.husky/post-checkout index eac9a9a7c..6d21e44b9 100644 --- a/.husky/post-checkout +++ b/.husky/post-checkout @@ -3,9 +3,14 @@ # ### git commit message template ### git config commit.template .git/templatemessage -TICKETID=`git rev-parse --abbrev-ref HEAD | LC_ALL=en_US.utf8 grep -oP '((feature|bug|bugfix|fix|hotfix|task|chore)\/)\K\d{1,7}'` -echo "[POST_CHECKOUT] Setting template commit to $TICKETID" -echo "#$TICKETID: " > ".git/templatemessage" +TICKETID=`git rev-parse --abbrev-ref HEAD | LC_ALL=en_US.utf8 grep -oP '((feature|bug|bugfix|fix|hotfix|task|chore)\/)\K\d{1,7}' || true` +if [ -z "$TICKETID" ] +then + TICKETID="0" +fi +TEMPLATE="#$TICKETID: " +echo "[POST_CHECKOUT] Setting template commit to '$TEMPLATE'" +echo $TEMPLATE > ".git/templatemessage" # ### run npm install ###