Merge pull request #932 from spacewander/git-su

git-summary: support filtering `--line` with path
This commit is contained in:
罗泽轩 2021-07-22 10:51:02 +08:00 committed by GitHub
commit 3821b2c537
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 16 deletions

View file

@ -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
@ -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

View file

@ -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\.
@ -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
@ -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:
@ -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>

View file

@ -76,7 +76,7 @@
<h2 id="SYNOPSIS">SYNOPSIS</h2>
<p><code>git-summary</code> [--line] [--dedup-by-email] [&lt;committish&gt;]</p>
<p><code>git-summary</code> [--line] [--dedup-by-email] [&lt;committish or path&gt;]</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
@ -88,6 +88,10 @@
<p> Summarize only the range of commits included in the &lt;committish&gt;.</p>
<p> &lt;path&gt;</p>
<p> Summarize only the range of files included in the &lt;path&gt;.</p>
<p> --dedup-by-email</p>
<p> Remove duplicate authors who belong to the same email address.
@ -108,7 +112,7 @@ $ git summary --dedup-by-email
<p> --line</p>
<p> Summarize with lines other than commits.
Any &lt;committish&gt; is ignored when --line is specified.</p>
When <code>--line</code> is specified, the last argument is treated as &lt;path&gt;.</p>
<h2 id="EXAMPLES">EXAMPLES</h2>
@ -158,11 +162,19 @@ authors :
...
</code></pre>
<p> The committish is ignored when --line is specified.</p>
<p> Filter with the path:</p>
<pre><code>$ git summary --line bin/
project : git-extras
lines : 4420
authors :
...
</code></pre>
<h2 id="AUTHOR">AUTHOR</h2>
<p>Written by Tj Holowaychuk &lt;<a href="&#109;&#97;&#105;&#108;&#x74;&#x6f;&#58;&#116;&#106;&#x40;&#x76;&#x69;&#x73;&#x69;&#x6f;&#110;&#x2d;&#x6d;&#101;&#x64;&#105;&#x61;&#x2e;&#99;&#97;" data-bare-link="true">&#x74;&#106;&#x40;&#118;&#x69;&#x73;&#105;&#x6f;&#x6e;&#45;&#x6d;&#x65;&#x64;&#x69;&#x61;&#46;&#99;&#97;</a>&gt;</p>
<p>Written by Tj Holowaychuk &lt;<a href="&#109;&#x61;&#105;&#x6c;&#116;&#x6f;&#x3a;&#116;&#x6a;&#x40;&#118;&#x69;&#x73;&#x69;&#x6f;&#110;&#x2d;&#109;&#101;&#100;&#x69;&#97;&#x2e;&#99;&#x61;" data-bare-link="true">&#116;&#106;&#x40;&#x76;&#105;&#115;&#105;&#111;&#110;&#x2d;&#109;&#101;&#100;&#105;&#x61;&#x2e;&#99;&#97;</a>&gt;</p>
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
@ -175,7 +187,7 @@ authors :
<ol class='man-decor man-foot man foot'>
<li class='tl'></li>
<li class='tc'>August 2020</li>
<li class='tc'>July 2021</li>
<li class='tr'>git-summary(1)</li>
</ol>

View file

@ -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
@ -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.
@ -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
@ -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