Skip to content

Instantly share code, notes, and snippets.

@rnaveiras
Created January 3, 2012 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnaveiras/1557582 to your computer and use it in GitHub Desktop.
Save rnaveiras/1557582 to your computer and use it in GitHub Desktop.
git changelog
#!/bin/sh
if [ $# = 1 ]; then NEW_TAG=$1; else NEW_TAG="x.y.z"; fi
CHANGELOG="History.md"
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](https://github.com/bebanjo/$PROJECT/compare/$LAST_TAG...$NEW_TAG)\n"
tmp='/tmp/changelog'
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
[ -n "$EDITOR" ] && $EDITOR $CHANGELOG
@rnaveiras
Copy link
Author

== Install ==

curl https://raw.github.com/gist/1557582/c9331cc8485ea6f654afd040848c4f621fee1474/git-changelog > /usr/local/bin/git-changelog && chmod +x /usr/local/bin/git-changelog

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

ex:
git changelog v1.0.0

== Result: Open a History.md 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