Benutzer-Werkzeuge

Webseiten-Werkzeuge


it-wiki:git:automatically_generate_changelog_md_file_with_git_commit

Dies ist eine alte Version des Dokuments!


A simple bash script to automatically generate a CHANGELOG.md file with every git commit

#!/bin/bash
set -eu
 
# destination of the final changelog file
OUTPUT_FILE=CHANGELOG.md
 
# generate the changelog
git --no-pager log --no-merges --format="### %s%d%n>%aD%n%n>Author: %aN (%aE)%n%n>Commiter: %cN (%cE)%n%n%b%n%N%n" > $OUTPUT_FILE
 
# prevent recursion!
# since a 'commit --amend' will trigger the post-commit script again
# we have to check if the changelog file has changed or not
res=$(git status --porcelain | grep -c ".\$OUTPUT_FILE$")
if [ "$res" -gt 0 ]; then
  git add $OUTPUT_FILE
  git commit --amend
  echo "Populated Changelog in $OUTPUT_FILE"
fi
it-wiki/git/automatically_generate_changelog_md_file_with_git_commit.1672986826.txt.gz · Zuletzt geändert: 2023/01/06 06:33 von marko