Joshua Joshua - 1 year ago 117
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


  • [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 Source

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().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download