Skip to content

Instantly share code, notes, and snippets.

@enyo
Created Jul 3, 2013
Embed
What would you like to do?
Print changelog to use for Github releases. (Goes through all commits, and shows the one with a #changelog hashtag)
#!/bin/bash
#echo git log $1...$2 --pretty=format:'<li> <a href="http://github.com/jerel/<project>/commit/%H">view commit &bull;</a> %s</li> ' --reverse | grep "#changelog"
firstTag=$(git tag | tail -2 | head -1)
secondTag=$(git tag | tail -1)
cmd=$(basename $0)
if [ "$1" == "-h" ]
then
echo ""
echo "Usage:"
echo " '$cmd' prints the changelog from the last two tags"
echo " '$cmd v1.0.0' prints the changelog from v1.0.0 to the latest tag except if:"
echo " '$cmd HEAD' which prints the changelog from the latest tag to HEAD"
echo " '$cmd v1.0.0 v2.0.0' prints the changelog from v1.0.0 to v2.0.0"
echo ""
exit
fi
if [ $# -eq 2 ]
then
firstTag=$1
secondTag=$2
else
if [ $# -eq 1 ]
then
if [ "$1" == "HEAD" ]
then
secondTag="HEAD"
else
firstTag=$1
fi
fi
fi
echo
echo "Type '$cmd -h' for usage"
echo
echo "CHANGELOG from $firstTag to $secondTag"
echo
git log $firstTag...$secondTag --pretty=format:'- [%h](https://github.com/enyo/dropzone/commit/%H) %s ||||>>>> %b' --reverse | grep "#changelog" | sed 's/^\(.*\)||||>>>>.*$/\1/'
echo
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment