Skip to content

Instantly share code, notes, and snippets.

@camilleriluke
Last active February 9, 2019 07:50
Show Gist options
  • Save camilleriluke/818b92480a7a6d7a5380 to your computer and use it in GitHub Desktop.
Save camilleriluke/818b92480a7a6d7a5380 to your computer and use it in GitHub Desktop.
prepare-commit-msg
#!/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
@FrelliBB
Copy link

Small nitpick:

"does not contain and issue id"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment