Created
January 3, 2012 23:36
-
-
Save rnaveiras/1557582 to your computer and use it in GitHub Desktop.
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
== 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