Reputation: 2677
Sample data
commit 3866ef2ff766054a188475ff100eeea
Author: user1
Date: Fri Nov 1 12:41:39 2019 +0000
JIRA-31326
Update pbr-support-3-col-title-links.jsp
commit a976d88e8e1d8f1489a93df3b65de77a72
Author: user2
Date: Fri Nov 1 12:33:18 2019 +0000
JIRA-31326
Update pbr-coveo-search.jsp
commit 04130086cadd5e552a9b327860720b2637bf
Author: user1
Date: Fri Nov 1 12:26:24 2019 +0000
JIRA-31327
Update pbr-company-article-hero.jsp
I want to grep the Jira Id and find the commit Id for the respective grep. It is much simpler in Linux
git log | grep 32468 -B4 | awk '{print $2}'
But unfortunately -B switch is not supported in AIX for grep.
Any help would be appreciated
Upvotes: 0
Views: 351
Reputation: 7627
Use --grep
option and --format=%H
to print the commit hash:
git log --grep 'JIRA-32468' --format=%H
Upvotes: 2
Reputation: 7235
Something like with awk
can do the work:
awk '/commit/{a=$2} $1 ~ "JIRA" {split($0,b,"-"); print a,b[2]}' input_file
Upvotes: 1