public
Created

git changelog

  • Download Gist
git-changelog
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/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

== 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.