Last active
December 20, 2015 20:19
-
-
Save bracke/6189629 to your computer and use it in GitHub Desktop.
Git hook: prepare-commit-msg
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
#!/bin/sh | |
# | |
# Based on http://blog.bartoszmajsak.com/blog/2012/11/07/lazy-developers-toolbox-number-1-prepend-git-commit-messages/ | |
# | |
BRANCH_NAME=$(git branch 2>/dev/null | grep -e ^* | tr -d ' *') | |
if [ -n "$BRANCH_NAME" ] && [ "$BRANCH_NAME" != "master" ]; then | |
echo "[$BRANCH_NAME] $(cat $1)" > $1 | |
fi | |
# | |
# Based on David Winterbottoms prepare-commit-msg | |
# http://codeinthehole.com/writing/enhancing-your-git-commit-editor/ | |
# | |
echo "# Last 5 commit messages" >> $1 | |
echo "# ----------------------" >> $1 | |
COMMITS=`git log --pretty=format:"# %h %s [%an]" -5` | |
echo "${COMMITS}" >> $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment