Created
October 22, 2012 02:34
-
-
Save danmactough/3929322 to your computer and use it in GitHub Desktop.
Custom git-changelog
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 | |
DATE=`date +'%Y-%m-%d'` | |
HEAD="\nn.n.n / $DATE \n==================\n\n" | |
function gcl () { | |
version=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1)) | |
if test -z "$version"; then | |
git log --no-merges --pretty="format: * %s (%an)" | |
else | |
git log --no-merges --pretty="format: * %s (%an)" $version.. | |
fi | |
} | |
case "$1" in | |
-l|--list) | |
gcl | |
;; | |
*) | |
CHANGELOG=$1 | |
if test "$CHANGELOG" = ""; then | |
CHANGELOG=`ls | egrep 'change|history' -i` | |
if test "$CHANGELOG" = ""; then CHANGELOG='History.md'; fi | |
fi | |
tmp="/tmp/changelog" | |
printf "$HEAD" > $tmp | |
gcl >> $tmp | |
printf '\n' >> $tmp | |
if [ -f $CHANGELOG ]; then cat $CHANGELOG >> $tmp; fi | |
mv $tmp $CHANGELOG | |
test -n "$EDITOR" && $EDITOR $CHANGELOG | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment