Skip to content

Instantly share code, notes, and snippets.

@lastguest
Created June 26, 2017 10:21
Show Gist options
  • Save lastguest/b22004a52383d7e18138d87dee26056c to your computer and use it in GitHub Desktop.
Save lastguest/b22004a52383d7e18138d87dee26056c to your computer and use it in GitHub Desktop.
[GIT Changelog] GIT Tag-based Changelog Generator #git #changelog #shell
#!/bin/sh
# GIT CHANGELOG Generator
# Stefano Azzolini <[email protected]>
#
# Use parameter --skip-head to skip HEAD section
LOG_FORMAT="\`%h\` **%s** _by %an_ "
function changelog_for_tag() {
echo "## $2\n"
git --no-pager log $1...$2 --pretty=format:"$LOG_FORMAT" --no-merges --no-color
echo "\n"
}
LAST_TAG="HEAD"
for TAG in `git tag -l | tail -r | grep '^\d'`; do
if [ "$LAST_TAG" == "HEAD" ] && [ $1 == '--skip-head' ]; then
LAST_TAG=$TAG
continue
fi
changelog_for_tag $TAG $LAST_TAG
LAST_TAG=$TAG
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment