Created
August 27, 2014 07:50
-
-
Save juliengdt/e167cee78c364ac02e80 to your computer and use it in GitHub Desktop.
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 | |
# author: julien gdt | |
# regex='^[\[](ADD|IMP|FIX)[\]]' | |
# regexjira='^[\[]JIRA[\]][[:space:]][\#][0-9]' | |
# regexversion='^Version[[:space:]][0-9]\.[0-9]\.[0-9][[space:]][a-zA-Z]{3,}' | |
var=`head -n 1 "$1"` | |
function info | |
{ | |
echo >&2 $1 | |
} | |
function debug | |
{ | |
debug=false | |
if $debug | |
then | |
echo >&2 $1 | |
fi | |
} | |
info "Your message is :" | |
info "$var" | |
info "" | |
if [[ "$var" =~ ^[\[](ADD|IMP|FIX)[\]] ]]; then | |
info "i know what you did there ..." | |
debug "Commit message: OK" | |
else | |
if [[ "$var" =~ ^[\[]JIRA[\]][[:space:]][\#][0-9] ]]; then | |
info "i know what u did there..." | |
debug "Commit JIRA fix: OK" | |
else | |
if [[ "$var" =~ ^[\[]VERSION[\]][[:space:]][0-9]\.[0-9]\.[0-9] ]]; then | |
info "i know what u did there..." | |
debug "Commit Version change: OK" | |
else | |
#Define format message for first line in commit message | |
info "[POLICY] message needs to be formatted like this:" | |
info "\"[ADD|IMP|FIX] - message\"" | |
info "or" | |
info "\"[JIRA] #JIRA_NUMBER\"" | |
info "or" | |
info "\"[VERSION] x.y.z\"" | |
info "Please modify your commit message ! =]" | |
exit 1 | |
fi | |
fi | |
fi | |
file="DEVCHANGELOG.md" | |
if [ -f "$file" ]; then | |
rm -f $file | |
fi | |
#execute git-changelog | |
./git/git-changelog > $file | |
debug "DEVCHANGELOG.md generated !" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment