Last active
February 9, 2019 07:50
-
-
Save camilleriluke/818b92480a7a6d7a5380 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/sh | |
# Add this in your .git/hooks folder | |
firstLine=$(head -n1 $1) | |
if [ -z "$firstLine" ] ;then | |
BRANCH_NAME=`git rev-parse --abbrev-ref HEAD` | |
APPEND_TO_COMMIT_MSG="# Branch does not contain an issue id, feel free to add your own.\n\n# Casumo/Home#" | |
if [[ $BRANCH_NAME == iss* ]]; then | |
APPEND_TO_COMMIT_MSG="`echo $BRANCH_NAME | sed -e 's/iss\([0-9]*\)\(.*\)/# Casumo\/Home#\1/g'`" | |
fi | |
exec 3<> $1 && awk -v TEXT="\n$APPEND_TO_COMMIT_MSG" 'BEGIN {print TEXT}{print}' $1 >&3 | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Small nitpick:
"does not contain and issue id"