Skip to content

Commit

Permalink
git-summary: support filtering --line with path
Browse files Browse the repository at this point in the history
  • Loading branch information
spacewander committed Jul 9, 2021
1 parent d28ad34 commit ffad35c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 16 deletions.
12 changes: 8 additions & 4 deletions bin/git-summary
Expand Up @@ -156,14 +156,18 @@ single_file() {
# list the author for all file
#
lines() {
git ls-files | single_file
if [ -n "$1" ]; then
git ls-files -- $1 | single_file
else
git ls-files | single_file
fi
}

#
# get the number of the lines
#
line_count() {
lines | wc -l
lines $1 | wc -l
}

# summary
Expand All @@ -172,9 +176,9 @@ echo
echo " project : $project"

if [ -n "$SUMMARY_BY_LINE" ]; then
echo " lines : $(line_count)"
echo " lines : $(line_count $commit)"
echo " authors :"
lines | sort | uniq -c | sort -rn | format_authors
lines $commit | sort | uniq -c | sort -rn | format_authors
else

# shellcheck disable=SC2046
Expand Down
29 changes: 25 additions & 4 deletions man/git-summary.1
@@ -1,13 +1,13 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-SUMMARY" "1" "August 2020" "" "Git Extras"
.TH "GIT\-SUMMARY" "1" "July 2021" "" "Git Extras"
.
.SH "NAME"
\fBgit\-summary\fR \- Show repository summary
.
.SH "SYNOPSIS"
\fBgit\-summary\fR [\-\-line] [\-\-dedup\-by\-email] [<committish>]
\fBgit\-summary\fR [\-\-line] [\-\-dedup\-by\-email] [<committish or path>]
.
.SH "DESCRIPTION"
Shows a summary of the repository\.
Expand All @@ -19,6 +19,12 @@ Shows a summary of the repository\.
Summarize only the range of commits included in the <committish>\.
.
.P
<path>
.
.P
Summarize only the range of files included in the <path>\.
.
.P
\-\-dedup\-by\-email
.
.P
Expand Down Expand Up @@ -48,7 +54,7 @@ This option can not be used together with \fB\-\-line\fR\.
\-\-line
.
.P
Summarize with lines other than commits\. Any <committish> is ignored when \-\-line is specified\.
Summarize with lines other than commits\. When \fB\-\-line\fR is specified, the last argument is treated as <path>\.
.
.SH "EXAMPLES"
Outputs a repo summary:
Expand Down Expand Up @@ -120,7 +126,22 @@ authors :
.IP "" 0
.
.P
The committish is ignored when \-\-line is specified\.
Filter with the path:
.
.IP "" 4
.
.nf

$ git summary \-\-line bin/

project : git\-extras
lines : 4420
authors :
\.\.\.
.
.fi
.
.IP "" 0
.
.SH "AUTHOR"
Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR>
Expand Down
22 changes: 17 additions & 5 deletions man/git-summary.html

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

17 changes: 14 additions & 3 deletions man/git-summary.md
Expand Up @@ -3,7 +3,7 @@ git-summary(1) -- Show repository summary

## SYNOPSIS

`git-summary` [--line] [--dedup-by-email] [&lt;committish&gt;]
`git-summary` [--line] [--dedup-by-email] [&lt;committish or path&gt;]

## DESCRIPTION

Expand All @@ -15,6 +15,10 @@ Shows a summary of the repository.

Summarize only the range of commits included in the &lt;committish&gt;.

&lt;path&gt;

Summarize only the range of files included in the &lt;path&gt;.

--dedup-by-email

Remove duplicate authors who belong to the same email address.
Expand All @@ -34,7 +38,7 @@ Shows a summary of the repository.
--line

Summarize with lines other than commits.
Any &lt;committish&gt; is ignored when --line is specified.
When `--line` is specified, the last argument is treated as &lt;path&gt;.

## EXAMPLES

Expand Down Expand Up @@ -81,7 +85,14 @@ Shows a summary of the repository.
authors :
...

The committish is ignored when --line is specified.
Filter with the path:

$ git summary --line bin/

project : git-extras
lines : 4420
authors :
...

## AUTHOR

Expand Down

0 comments on commit ffad35c

Please sign in to comment.