Created
May 13, 2019 22:53
-
-
Save joseph-henry/7d43379ffa39db1af99903fd9fe6c84d to your computer and use it in GitHub Desktop.
Generate markdown CHANGELOG from git-log with included comparison links
This file contains hidden or 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/bash | |
generate_changelog() | |
{ | |
github_user="user" | |
github_project_name="project" | |
first_commit=$(git rev-list --max-parents=0 HEAD) | |
git for-each-ref --sort=-refname --format="## [%(refname:short)] - %(taggerdate:short) &(newline)*** &(newline)- %(subject) %(body)" refs/tags > CHANGELOG.md | |
gsed -i '''s/\&(newline)/\n/' CHANGELOG.md # replace first instance | |
gsed -i '''s/\&(newline)/\n/' CHANGELOG.md # replace second instance | |
echo -e "\n" >> CHANGELOG.md | |
for curr_tag in $(git tag -l --sort=-v:refname) | |
do | |
prev_tag=$(git describe --abbrev=0 ${curr_tag}^) | |
if [ -z "${prev_tag}" ] | |
then | |
prev_tag=${first_commit} | |
fi | |
echo "[${curr_tag}]: https://github.com/${github_user}/${github_project_name}/compare/${prev_tag}..${curr_tag}" >> CHANGELOG.md | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment