Open chiliang7 opened 1 year ago
I use a one-liner to extract info from a git
command. For example, with git show
, you get more data than needed. To filter it, use --shortstat
and --format=
, resulting in this:
6 files changed, 366 insertions(+), 2 deletions(-)
You can use awk
to extract numbers from text by specifying -F '[^0-9]+'
as the field separator, which separates digits from non-digits in the input line. This allows you to isolate the numeric values.
awk -F '[^0-9]+' '{print $2","$3","$4}'
So, awk
extracts the second (we skip the first field as it's a space), third, and fourth fields from the input. These fields contain the numbers we need, and awk prints them with commas in between:commas between:
6,366,2
Here's the complete command:
git show --shortstat --format= | awk -F '[^0-9]+' '{print $2","$3","$4}'
Is your feature request related to a problem? Please describe.
Perhaps, the functionality exists but I couldn't find it but it would be nice to include lines added/deleted from the merge commits
Describe the solution you'd like The final output should include the line stats from merge commit
Thanks