Created
December 22, 2015 09:01
-
-
Save avivl/5147c671a7ef1e010c7a to your computer and use it in GitHub Desktop.
prepare-commit-msg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
branch_name=$(git symbolic-ref -q HEAD | awk '{split($0,a,"/"); print a[length(a)]}' | awk '{split($0,a,"_"); print a[1]}') | |
first_line=$(head -n1 $1) | |
if [ -z "$first_line" ] ;then # Check that this is not an amend by checking that the first line is empty | |
sed -i '' "1s/^/$branch_name \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