Overview
The Git log is a command that shows the commit history for a repository, including information about who made the commit, when it was made, and what changes were made.
In order to create a release notes document using the Git log, I used a shell script which should first check out the repository name and then run git log command with the appropriate options to retrieve the history. The output of the Git log will be showing version of repo, update date, and commit messages.
Demo Video
Code
#!/bin/bash
REPO_NAME=$(git config --get remote.origin.url | xargs basename | sed 's/\.git$//')
# echo "CHANGELOG"
# echo ----------------------
git for-each-ref --sort='*authordate' --format='%(tag)' refs/tags |tac |grep -v '^$' | while read TAG ; do
echo
TAG_DATE=$(git log -1 --format=%cs $NEXT)
if [ $NEXT ];then
echo -e "\n## [$NEXT] - $TAG_DATE" >> CHANGELOG.md
else
echo -e "## [Release Note]" >> CHANGELOG.md
fi
GIT_PAGER=cat git log --merges --format=" - %s ([#%h](https://dev.azure.com/CeridianHosting/Infrastructure%20Engineering/_git/$REPO_NAME/commit/%H?refName=refs/heads/master))" $TAG..$NEXT >> CHANGELOG.md
NEXT=$TAG
done
FIRST=$(git tag -l | head -1)
FIRST_DATE=$(git log -1 --format=%cs $FIRST)
echo -e "\n\n## [$FIRST] - $FIRST_DATE" >> CHANGELOG.md
GIT_PAGER=cat git log --no-merges --format=" - %s ([#%h](https://dev.azure.com/CeridianHosting/Infrastructure%20Engineering/_git/$REPO_NAME/commit/%H?refName=refs/heads/master))" $FIRST >> CHANGELOG.md