Menu
  • Home
  • About Me
  • Blog
  • Github
  • LinkedIn

Demo: Git Log with Shell script to create a release notes

April 11, 2023April 13, 2023

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

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts
  • ChinguTalkBot v0.1.0: Setting up AWS Cognito with CDK for User Authentication
  • Phoenix & Elixir: Fix PostgreSQL connection refused
  • Demo: Git Log with Shell script to create a release notes
  • Metasploit
  • CyberSecurity Lab – Online Password Attack

Archives
  • March 2024
  • May 2023
  • April 2023
  • February 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
Categories
  • Amazon Interview (3)
  • Ansible (3)
  • AWS (9)
  • Azure (9)
  • Certification (2)
  • ChinguTalkBot Project (1)
  • cybersecurity (3)
  • Data analytics (6)
  • Demo Videos (6)
  • Docker (5)
  • Git (1)
  • GitLab (1)
  • Golang (3)
  • JavaScript (2)
  • Jenkins (4)
  • PowerShell (1)
  • Python (10)
  • Terraform (11)
  • Uncategorized (9)

©2025 | Powered by WordPress and Superb Themes!