Skip to content

Commit

Permalink
Added git summary --author-commit-limit option which filters author
Browse files Browse the repository at this point in the history
listing.
  • Loading branch information
tfendin committed Jul 27, 2023
1 parent 38a14f0 commit a595c68
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
10 changes: 10 additions & 0 deletions bin/git-summary
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SUMMARY_BY_LINE=
DEDUP_BY_EMAIL=
MERGES_ARG=
OUTPUT_STYLE=
AUTHOR_COMMIT_LIMIT=0
for arg in "$@"; do
case "$arg" in
--line)
Expand All @@ -28,6 +29,10 @@ for arg in "$@"; do
OUTPUT_STYLE="$2"
shift
;;
--author-commit-limit)
AUTHOR_COMMIT_LIMIT="$2"
shift
;;
-*)
>&2 echo "unknown argument $arg found"
exit 1
Expand Down Expand Up @@ -143,9 +148,14 @@ format_authors() {
# author name. However, Linux column utility will escape tab if separator
# specified, so we do unesaping after it.
LC_ALL=C awk '
BEGIN {
commitLimit = strtonum('"${AUTHOR_COMMIT_LIMIT}"');
}
{ args[NR] = $0; sum += $0 }
END {
for (i = 1; i <= NR; ++i) {
if (strtonum(args[i]) < commitLimit)
break;
printf "%s♪%2.1f%%\n", args[i], 100 * args[i] / sum
}
}
Expand Down
6 changes: 5 additions & 1 deletion man/git-summary.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.SH "NAME"
\fBgit\-summary\fR \- Show repository summary
.SH "SYNOPSIS"
\fBgit\-summary\fR [\-\-dedup\-by\-email] [\-\-no\-merges] [<committish>]
\fBgit\-summary\fR [\-\-dedup\-by\-email] [\-\-no\-merges] [\-\-author\-commit\-limit <count>] [<committish>]
.P
\fBgit\-summary\fR \-\-line [<path>]
.SH "DESCRIPTION"
Expand Down Expand Up @@ -38,6 +38,10 @@ $ git summary \-\-dedup\-by\-email
.P
Exclude merge commits\.
.P
\-\-author\-commit\-limit <count>
.P
Omit authors with less than <count> authored commits from author listing\. Defaults to zero\.
.P
\-\-line
.P
Summarize with lines other than commits\. When \fB\-\-line\fR is specified, the last argument is treated as <path>\.
Expand Down
6 changes: 5 additions & 1 deletion man/git-summary.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/git-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ git-summary(1) -- Show repository summary

## SYNOPSIS

`git-summary` [--dedup-by-email] [--no-merges] [&lt;committish&gt;]
`git-summary` [--dedup-by-email] [--no-merges] [--author-commit-limit &lt;count&gt;] [&lt;committish&gt;]

`git-summary` --line [&lt;path&gt;]

Expand Down Expand Up @@ -39,6 +39,10 @@ Shows a summary of the repository or a path within it.

Exclude merge commits.

--author-commit-limit &lt;count&gt;

Omit authors with less than &lt;count&gt; authored commits from author listing. Defaults to zero.

--line

Summarize with lines other than commits.
Expand Down

0 comments on commit a595c68

Please sign in to comment.