Skip to content

Instantly share code, notes, and snippets.

@TheHippo
Created January 27, 2015 15:45
Show Gist options
  • Save TheHippo/dfe5169d6661a7b650a2 to your computer and use it in GitHub Desktop.
Save TheHippo/dfe5169d6661a7b650a2 to your computer and use it in GitHub Desktop.
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