Skip to content

Commit

Permalink
modified my commit hoock to take merge commits into acount
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsEckart committed Mar 24, 2023
1 parent 8c6e70e commit 0cdb700
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion githooks/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
FILE=$1
MESSAGE=$(cat $FILE)
TICKET=$(git rev-parse --abbrev-ref HEAD | grep -Eo '^(\w+/)?\w+[-_][0-9]+' | grep -Eo '\w+[-][0-9]+' | tr "[:lower:]" "[:upper:]")
if [[ $TICKET == "" || $MESSAGE == "Merge"* || "$MESSAGE" == "$TICKET"* ]];then
if [[ $TICKET == "" ]];then
echo 'Branch name without ticket information, keeping git message as is.'
exit 0;
fi
if [[ $MESSAGE == "Merge"* ]];then
echo 'Merge commit, keeping git message as is.'
exit 0;
fi
if [[ "$MESSAGE" == "$TICKET"* ]];then
echo 'ticket information already present, keeping git message as is.'
exit 0;
fi


echo "$TICKET $MESSAGE" > $FILE

0 comments on commit 0cdb700

Please sign in to comment.