Create a gist now

Instantly share code, notes, and snippets.

git changelog
if [ $# = 1 ]; then NEW_TAG=$1; else NEW_TAG="x.y.z"; fi
DATE=`date +'%Y-%m-%d'`
LAST_TAG=`git for-each-ref refs/tags --sort=-authordate --format='%(refname)' --count=1 | sed 's/^refs\/tags\///'`
if [ -z $LAST_TAG ]; then LAST_TAG='master'; fi
PROJECT=`git remote -v |grep -E '^origin.*fetch\)$' | cut -d '/' -f2 |cut -d '.' -f1`
HEAD=" $NEW_TAG / $DATE \n==================\n \n [full changelog]($PROJECT/compare/$LAST_TAG...$NEW_TAG)\n"
echo $HEAD >> $tmp
git log --pretty="format: * %s" $LAST_TAG.. >> $tmp
echo '\n' >> $tmp
if [ -f $CHANGELOG ]; then cat $CHANGELOG >> $tmp; fi
mv $tmp $CHANGELOG

== Install ==

curl > /usr/local/bin/git-changelog && chmod +x /usr/local/bin/git-changelog

== Use==
Go to a repo git
git changelog new_tag

git changelog v1.0.0

== Result: Open a in your $EDITOR ==

v1.0.0 / 2012-01-04

full changelog

  • Commit description
  • Commit description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment