Skip to content

Commit

Permalink
imported contrib/generate-changelog from tklx/base and tweaked
Browse files Browse the repository at this point in the history
  • Loading branch information
alonswartz committed Jul 5, 2016
1 parent 1b400ec commit 3c4a6b7
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions contrib/generate-changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash -e

fatal() { echo "fatal [$(basename $0)]: $@" 1>&2; exit 1; }

usage() {
cat<<EOF
Syntax: $0
Convenience script to output updated CHANGELOG.md for manual editing
Notes::
- auto-increments major.minor.PATCH from latest git tag (or 0.1.0)
- includes short git log of changes since latest git tag (or all)
EOF
exit 1
}

increment_version() {
version=$1
last_char=${version#${version%?}}
echo $version | sed 's/[0-9]$/'"$((last_char+1))"'/'
}

get_log() {
since=$1
[ "$since" ] && between=$since..HEAD
git --no-pager log $between --reverse --pretty=format:'- %s'
}

[[ "$#" = "0" ]] || usage

latest=$(git tag -l | head -1)
gitlog=$(get_log $latest)
[ "$latest" ] && version=$(increment_version $latest)

echo -e "## ${version:-0.1.0}\n"
echo -e "<replace with high level summary>\n"
echo -e "#### New features\n"
echo -e "#### Bugfixes\n"
echo "${gitlog}" | grep fix && echo || true
echo -e "#### Other changes\n"
echo "${gitlog}" | grep -v fix && echo || true
[ -e CHANGELOG.md ] && cat CHANGELOG.md

exit 0

0 comments on commit 3c4a6b7

Please sign in to comment.