Joshua
Joshua

Reputation: 1961

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:

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

Upvotes: 3

Views: 533

Answers (1)

qzb
qzb

Reputation: 8828

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

Upvotes: 2

Related Questions