Created
January 27, 2015 15:45
-
-
Save TheHippo/dfe5169d6661a7b650a2 to your computer and use it in GitHub Desktop.
Prepare and verify angular.js styled commit message with git flow
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 | |
# | |
# 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 |
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 | |
# | |
# 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