Skip to content

Instantly share code, notes, and snippets.

@TheHippo TheHippo/commit-msg
Created Jan 27, 2015

Embed
What would you like to do?
Prepare and verify angular.js styled commit message with git flow
#!/bin/bash
#
# abort commit if on feature/branch and nothing else than auto generated commit message
# is entered
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ $current_branch == "feature/"* ]]
then
first_line=$(head -n 1 $1)
if [[ $first_line == "(${current_branch:8}):" ]]; then
echo 'No valid commit message entered.'
exit 1
fi
fi
exit 0
#!/bin/bash
#
# if you are about to create a new commit (no amend, no merge, no squash)
# prepopulate commit message with angular.js style commit message
case "$2" in
"" | "message") #commit with message or without
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ $current_branch == "feature/"* ]]
then
echo -e "(${current_branch:8}):\n$(cat $1)" > $1
fi
;;
"template" | "merge" | "squash" | "commit")
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.