Skip to content

Instantly share code, notes, and snippets.

@danmactough
Created October 22, 2012 02:34
Show Gist options
  • Save danmactough/3929322 to your computer and use it in GitHub Desktop.
Save danmactough/3929322 to your computer and use it in GitHub Desktop.
Custom git-changelog
#!/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