#!/bin/sh
# A hook script to prepare the commit log message.
# If the branch name it's a jira Ticket.
# It adds the branch name to the commit message, if it is not already part of it.
branchPath=$(git symbolic-ref -q HEAD) #Somthing like refs/heads/myBranchName
branchName=#$(basename "$branchPath"):
TICKET=$(git rev-parse --abbrev-ref HEAD | grep -Eo '^(w+/)?(w+[-_])?[0-9]+' | grep -Eo '(w+[-])?[0-9]+' | tr "[:lower:]" "[:upper:]")
if [$TICKET == ""] ; then
if [[$branchName == "#develop:*"]]; then
sed -i.bak -e "1s~^~#: ~" $1
else
sed -i.bak -e "1s~^~:# ~" $1
fi
else
sed -i.bak -e "1s~^~#$TICKET: ~" $1
fi
if [[$branchName == “#develop:*”]]; then // Something is not correct here, can someone help me to resolve it?