Create a Changelog from `git log`
On a regular basis, you may want to tag the master branch with a (beta) version that is deployed to a customer's staging system.
People not engaged in development themselves (e.g. product owners) usually have a hard time following the changes that are made available with each new version. So the easiest way to help them is to create a readable changelog from the git log.
How we do it
We use GitLab, which requires us to work with so called "feature branches" and merge requests. Merge requests from the feature branches are usually merged into the master with a merge commit. This merge commit carries some of the description from the merge request, especially its subject.
In the end, the git log looks like the following:
The interesting parts here are the merge commits (denoted by the description starting with "Merge branch"). Those carry just enough information to create a changelog from them:
As you can see, we prefix the short description of the merge request with a tracker number from our ticketing system. 'CHGLOG' is the short title of the project and '556' is the ticket number within the system.
To create a changelog from this information from within the git repository, nothing more than the following bash script is needed:
This script outputs the following, which can be given to the product owner as soon as the next version has been deployed: