Q:

how to extract data using awk or grep from git log?

I have to extract commit message as well as the corresponding files changed from git log.
Basically, I have BUC IDs given in my commit message. So, for certain set of files I want to get BUC IDs.
Output of my command:    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/

Now I want to get BUC ID for only changes made in webui/.
How can I achieve that?

A:

The command will delete blank lines from output, filter by webui and print 2 lines before the webui match.
git log --dirstat | grep -ve '^$' | grep webui -B 2

