I'm running from the terminal in OSX, and given a git log format like:
* 58dbb08 Joe Blogs 5 weeks ago | [ABC-123] Commit message contents
* 5a9c5e1 Jane Doe 3 weeks ago | Commit Contents with XYZ-987 jira ticket number
* 6070ee0 Some Person 3 weeks ago | Commit which references [MNO-456, MNO-999]
I'd like to generate a list in the CLI (using git log, grep, sort, sed) on OSX which would print out the log in such a format:
58dbb08 │ ABC-123
5a9c5e1 │ XYZ-987
6070ee0 │ MNO-456, MNO-999
──────────│──────────────────────
ꜛ sha │ ꜛ jira tickets
The purpose is so our QA can extract a list of Jira Tickets which were referenced inside of git commits, and then easily find the associated commit/ticket by looking through the list
I've got little experience in sed
and having difficulties understanding the ways of extracting and replacing patterns, then printing only the matched patterns. I've read the docs, but some of the language is unfamiliar considering I rarely touch unix/regex, and I couldn't decipher how to extract multiple patterns and replace un-matched strings.
What I'm working with currently;
git log --oneline 7.2.0..HEAD |
grep -iEo "([a-f0-9]{7})(.*[a-zA-Z0-9]{2,6}-[0-9]{1,4})+" |
sort -u |
sed -n "s/\([a-zA-Z0-9]\{2,7\}-[0-9]\{1,4\}\)/, \1 /pg"
which gets me to;
58dbb08 Joe Blogs 5 weeks ago | [, ABC-123
5a9c5e1 Jane Doe 3 weeks ago | Commit Contents with , XYZ-987
6070ee0 Some Person 3 weeks ago | Commit which references [, MNO-456 , , MNO-999
which is close, but I can't get rid of the stuff I don't need