diff --git a/bin/git-summary b/bin/git-summary index ddb72cd2d..fece45465 100755 --- a/bin/git-summary +++ b/bin/git-summary @@ -3,10 +3,13 @@ cd "$(git root)" || { echo "Can't cd to top level directory";exit 1; } +AUTHOR_LISTING= + SUMMARY_BY_LINE= DEDUP_BY_EMAIL= MERGES_ARG= OUTPUT_STYLE= +AUTHOR_COMMIT_LIMIT=0 for arg in "$@"; do case "$arg" in --line) @@ -22,6 +25,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 @@ -136,10 +143,15 @@ format_authors() { # a rare unicode character is used as separator to avoid conflicting with # author name. However, Linux column utility will escape tab if separator # specified, so we do unesaping after it. - LC_ALL=C awk ' + echo "${1:?}" | 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 } } @@ -194,6 +206,10 @@ uncommitted_changes_count() { git status --porcelain | wc -l } +number_of_authors() { + echo "${1:?}" | wc -l +} + COLUMN_CMD_DELIMTER="¬" # Hopefully, this symbol is not used in branch names... I use it as a separator for columns SP="$COLUMN_CMD_DELIMTER|" @@ -208,8 +224,9 @@ print_summary_by_line() { echo echo " project : $project" echo " lines : $(line_count "${paths[@]}")" - echo " authors :" - lines "${paths[@]}" | sort | uniq -c | sort -rn | format_authors + local AUTHOR_LISTING=$(lines "${paths[@]}" | sort | uniq -c | sort -rn) + echo " authors : $(number_of_authors "${AUTHOR_LISTING}")" + format_authors "${AUTHOR_LISTING}" fi } @@ -235,15 +252,17 @@ print_summary() { echo " files : $(file_count)" fi echo " uncommitted : $(uncommitted_changes_count)" - echo " authors : " + local AUTHOR_LISTING if [ -n "$DEDUP_BY_EMAIL" ]; then # the $commit can be empty # shellcheck disable=SC2086 - git shortlog $MERGES_ARG -n -s -e $commit | dedup_by_email | format_authors + AUTHOR_LISTING=$(git shortlog $MERGES_ARG -n -s -e $commit | dedup_by_email) else # shellcheck disable=SC2086 - git shortlog $MERGES_ARG -n -s $commit | format_authors + AUTHOR_LISTING=$(git shortlog $MERGES_ARG -n -s $commit) fi + echo " authors : $(number_of_authors "${AUTHOR_LISTING}")" + format_authors "${AUTHOR_LISTING}" fi } diff --git a/man/git-summary.1 b/man/git-summary.1 index 87a3085a8..e0293c37b 100644 --- a/man/git-summary.1 +++ b/man/git-summary.1 @@ -1,10 +1,10 @@ .\" generated with Ronn-NG/v0.9.1 .\" http://github.com/apjanke/ronn-ng/tree/0.9.1 -.TH "GIT\-SUMMARY" "1" "June 2023" "" "Git Extras" +.TH "GIT\-SUMMARY" "1" "July 2023" "" "Git Extras" .SH "NAME" \fBgit\-summary\fR \- Show repository summary .SH "SYNOPSIS" -\fBgit\-summary\fR [\-\-dedup\-by\-email] [\-\-no\-merges] [] +\fBgit\-summary\fR [\-\-dedup\-by\-email] [\-\-no\-merges] [\-\-author\-commit\-limit ] [] .P \fBgit\-summary\fR \-\-line [] .SH "DESCRIPTION" @@ -38,6 +38,10 @@ $ git summary \-\-dedup\-by\-email .P Exclude merge commits\. .P +\-\-author\-commit\-limit +.P +Omit authors with less than 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 \. @@ -63,7 +67,7 @@ active on : 93 days commits : 1893 files : 111 uncommitted : 3 -authors : +authors : 18 1285 visionmedia 478 Tj Holowaychuk 48 Aaron Heckmann @@ -99,7 +103,7 @@ $ git summary \-\-line project : git\-extras lines : 26820 -authors : +authors : 206 \|\.\|\.\|\. .fi .IP "" 0 @@ -111,7 +115,7 @@ $ git summary \-\-line bin/ project : git\-extras lines : 4420 -authors : +authors : 141 \|\.\|\.\|\. .fi .IP "" 0 diff --git a/man/git-summary.html b/man/git-summary.html index ffcd49770..67dcdc78f 100644 --- a/man/git-summary.html +++ b/man/git-summary.html @@ -77,7 +77,7 @@

NAME

SYNOPSIS

-

git-summary [--dedup-by-email] [--no-merges] [<committish>]

+

git-summary [--dedup-by-email] [--no-merges] [--author-commit-limit <count>] [<committish>]

git-summary --line [<path>]

@@ -114,6 +114,10 @@

OPTIONS

Exclude merge commits.

+

--author-commit-limit <count>

+ +

Omit authors with less than <count> authored commits from author listing. Defaults to zero.

+

--line

Summarize with lines other than commits. @@ -147,7 +151,7 @@

EXAMPLES

commits : 1893 files : 111 uncommitted : 3 -authors : +authors : 18 1285 visionmedia 478 Tj Holowaychuk 48 Aaron Heckmann @@ -180,7 +184,7 @@

EXAMPLES

project : git-extras lines : 26820 -authors : +authors : 206 ... @@ -190,7 +194,7 @@

EXAMPLES

project : git-extras lines : 4420 -authors : +authors : 141 ... @@ -221,7 +225,7 @@

SEE ALSO

  1. -
  2. June 2023
  3. +
  4. July 2023
  5. git-summary(1)
diff --git a/man/git-summary.md b/man/git-summary.md index 11ca4bbb0..5f69bb9f7 100644 --- a/man/git-summary.md +++ b/man/git-summary.md @@ -3,7 +3,7 @@ git-summary(1) -- Show repository summary ## SYNOPSIS -`git-summary` [--dedup-by-email] [--no-merges] [<committish>] +`git-summary` [--dedup-by-email] [--no-merges] [--author-commit-limit <count>] [<committish>] `git-summary` --line [<path>] @@ -39,6 +39,10 @@ Shows a summary of the repository or a path within it. Exclude merge commits. + --author-commit-limit <count> + + Omit authors with less than <count> authored commits from author listing. Defaults to zero. + --line Summarize with lines other than commits. @@ -72,7 +76,7 @@ Shows a summary of the repository or a path within it. commits : 1893 files : 111 uncommitted : 3 - authors : + authors : 18 1285 visionmedia 478 Tj Holowaychuk 48 Aaron Heckmann @@ -103,7 +107,7 @@ Shows a summary of the repository or a path within it. project : git-extras lines : 26820 - authors : + authors : 206 ... Filter with the path: @@ -112,7 +116,7 @@ Shows a summary of the repository or a path within it. project : git-extras lines : 4420 - authors : + authors : 141 ... Tabular summary