Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
branchPath=$(git symbolic-ref -q HEAD) #Somthing like refs/heads/myBranchName
branchName=${branchPath##*/} #Get text behind the last / of the branch path
if [[ $branchName =~ tickety([[:digit:]]+) ]]; then
bnum=${BASH_REMATCH[1]};
heading="TICKETY-$bnum \/\/";
else
heading="($branchName) ";
fi
firstLine=$(head -n1 $1)
if [ -z "$firstLine" ] ;then #Check that this is not an amend by checking that the first line is empty
sed -i "1s/^/#$heading \n/" $1; #Insert branch name at the start of the commit message file
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment