I need to extract multiple words from git log.
I need the commit id and ticket number for each commit, I then need to run this through a loop and do some further processing for each commit.
commit 87b56bbd6496802bbc97c8abd0346597d7a15810 (HEAD -> main, tag: app_v4.151.6, origin/main, origin/HEAD) Author: daniel-johns-99 <[email protected]> Date: Thu Mar 27 21:11:18 2025 +1000 CI-451-template-change (#4497) commit 45bec837a19ac33822da2033bf1fb192b8cf2945 (tag: uk_v46, tag: app_v4.151.5) Author: Leon Duffus <[email protected]> Date: Thu Mar 27 09:16:51 2025 +0000 DTE-602 dsc breadcrumb component design changes (#4457) : given the above, I would need the following array that I could process
CI-451:87b56bbd6496802bbc97c8abd0346597d7a15810 DTE-602:45bec837a19ac33822da2033bf1fb192b8cf2945 the following is my current attempt:
commits=$(git log "$previous_tag".."$tag") for i in $commits; do commit=$(echo $i | sed 's/^.*commit //') ticket=$(echo $i | grep --extended-regexp --only-matching --ignore-case "(${proj_regex})[ -][0-9]{2,5}") echo $commit done