8

I'm trying to generate changelog to a project (repo in bitbucket.org), but I can't find an easy solution. We are using this pattern

(<type>(<scope>): <subject>)

to fill the commit messages, and tags to version (0.1, 0.2, 0.3).

Is there anything out-of-the-box (some script, npm package, etc...) or the best thing I can do is write some custom script using git log and parse the data (commit messages, etc...)?

I know there is an github-changelog-creator, but I can't use as long as this repo is in a bitbucket repo.

Christian Benseler
  • 7,907
  • 8
  • 40
  • 71
  • 2
    I firmly believe that changelogs should be created manually. Commit histories are very granular and exist at a technical level. Changelogs should be less granular and focused on user-facing changes. – ChrisGPT was on strike Nov 29 '16 at 13:02

1 Answers1

28

We are using this simple shell script to generate hierarchical change log sorted by tags with the latest tag on top.

#!/usr/bin/env bash
previous_tag=0
for current_tag in $(git tag --sort=-creatordate)
do

if [ "$previous_tag" != 0 ];then
    tag_date=$(git log -1 --pretty=format:'%ad' --date=short ${previous_tag})
    printf "## ${previous_tag} (${tag_date})\n\n"
    git log ${current_tag}...${previous_tag} --pretty=format:'*  %s [View](https://bitbucket.org/projects/test/repos/my-project/commits/%H)' --reverse | grep -v Merge
    printf "\n\n"
fi
previous_tag=${current_tag}
done

And you can put it in the project root as some shel file and run it (depending upon your platform you might need to make it executable) as below

sh change-log-builder.sh > changelog.md

And the resulting changelog.md looks like this


v1.1.0 (2017-08-29)

  • Adds IPv6 support [View]
  • Adds TreeMaker class and its test. [View]

v1.0.9 (2017-08-22)

  • Updates composer.json.lock [View]

v1.0.8 (2017-08-22)

  • Adds S3Gateway as substitute class [View]
  • Removes files no more used [View]
Waku-2
  • 1,136
  • 2
  • 13
  • 26