Last active
June 30, 2016 17:00
-
-
Save FMCorz/ce6250e01ace1edb1dcaa6ec69568532 to your computer and use it in GitHub Desktop.
Prepare commit message hook for Moodle
This file contains hidden or 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
# Add this to .git/hooks/prepare-commit-msg | |
# Then chmod +x .git/hooks/prepare-commit-msg | |
# | |
# /!\ Note, it is assumed that you have the alias `git cb` | |
# which returns the current branch. | |
if [ -z "$2" ]; then | |
branch=`git cb` | |
mdl=`expr match "$branch" 'MDL-\([0-9]\+\)-.*'` | |
if [ -n "$mdl" ]; then | |
echo -n "MDL-$mdl \n" > .git/CREATECOMMITMSG | |
cat $1 >> .git/CREATECOMMITMSG | |
mv .git/CREATECOMMITMSG $1 | |
fi | |
fi |
This file contains hidden or 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
[alias] | |
cb = "!echo $(b=$(git symbolic-ref -q HEAD); { [ -n \"$b\" ] && echo ${b##refs/heads/}; } || echo HEAD)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment