Joshua Joshua - 1 month ago 16
Git Question

Release notes from git log using bash awk

We follow a commit message policy that allows us to parse git log for release notes.

[category US123] Description of what is changed



eg:


  • [feature US123] Added the version number to the meta:version tag of every page. Better for support.

  • [dev US123] remove development entries before production

  • [settings US123] New STS webservice url for UAT



The bash script below parses the log, but there's a trailing number after each user story / defect.

Is this a side effect of awk? What needs to change to remove the trailing number?

git log -100 --pretty="%s" | grep -io "\(DE\|US\)[0-9]\{3,\}" | sort | uniq | awk '{print $1; print system("git log --pretty=\"%cI %an %s\" | grep -i -v \"Merge\" | grep -i "$1)}'


enter image description here

qzb qzb
Answer

You have to replace print system(...) with just system(...):

git log -100 --pretty="%s" | grep -io "\(DE\|US\)[0-9]\{3,\}" | sort | uniq | awk '{print $1; system("git log --pretty=\"%cI %an %s\" | grep -i -v \"Merge\" | grep -i "$1)}'

system() function prints to stdout by itself, when you call print system(...) you actually print exit code returned by system().

Comments