-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imported contrib/generate-changelog from tklx/base and tweaked
- Loading branch information
1 parent
1b400ec
commit 3c4a6b7
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
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 |