我必须提取提交消息以及从git log更改的相应文件。 基本上,我在提交消息中给出了BUC ID。因此,对于某些文件集,我想获得BUC ID。
输出我的命令:git log --dirstat
commit bcc9d8be62b6ac9b8dc02c0bf56d0f433df59466
Author:
Date: Tue Sep 5 12:08:04 2017 +0530
BUC:BUC3565-EPIC14 | Review Page Manage permission and junit
Change-Id: Ice73d25f77d9f6c4afe647e35bdf9ec280dd7dcf
31.3% manager/src/main/java/com/ericsson/cm/manager/web/listner/
68.6% manager/src/test/java/com/ericsson/cm/manager/web/listners/
commit ab70d068b2bcea4060028a3457551cd1cc35a1f1
Author:
Date: Tue Sep 5 11:30:29 2017 +0530
BUC:BUC12345 MADE some changes
Change-Id: I7e6733afaf8064c1279e5b217c8d4fba469fd061
59.0% webui/servermanagement/src/servermanagement/regions/left/
40.9% webui/servermanagement/src/servermanagement/regions/main/
现在我想BUC ID
仅对webui/
进行更改。{
我怎样才能做到这一点?
答案 0 :(得分:0)
$ awk -F'[: ]' '/BUC/{buc=$3;next}/webui/{print buc;exit}' logfile
BUC12345
# OR
$ awk '/BUC/{$1=$1;gsub(/BUC:| .*/,"");buc=$0}/webui/{print buc;exit}' logfile
BUC12345
输入:
$ cat logfile
commit bcc9d8be62b6ac9b8dc02c0bf56d0f433df59466
Author:
Date: Tue Sep 5 12:08:04 2017 +0530
BUC:BUC3565-EPIC14 | Review Page Manage permission and junit
Change-Id: Ice73d25f77d9f6c4afe647e35bdf9ec280dd7dcf
31.3% manager/src/main/java/com/ericsson/cm/manager/web/listner/
68.6% manager/src/test/java/com/ericsson/cm/manager/web/listners/
commit ab70d068b2bcea4060028a3457551cd1cc35a1f1
Author:
Date: Tue Sep 5 11:30:29 2017 +0530
BUC:BUC12345 MADE some changes
Change-Id: I7e6733afaf8064c1279e5b217c8d4fba469fd061
59.0% webui/servermanagement/src/servermanagement/regions/left/
40.9% webui/servermanagement/src/servermanagement/regions/main/
答案 1 :(得分:0)
该命令将从输出中删除空白行,在webui
匹配之前按2
过滤并打印webui
行。
git log --dirstat | grep -ve '^$' | grep webui -B 2