Skip to content

Commit 0edcf8b

Browse files
authored
Merge pull request #934 from tfendin/no-merge-summary
No merge summary
2 parents a07c5ec + a7b7f05 commit 0edcf8b

File tree

6 files changed

+64
-81
lines changed

6 files changed

+64
-81
lines changed

bin/git-summary

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ cd "$(git root)" || { echo "Can't cd to top level directory";exit 1; }
55

66
SUMMARY_BY_LINE=
77
DEDUP_BY_EMAIL=
8+
MERGES_ARG=
89
for arg in "$@"; do
910
case "$arg" in
1011
--line)
@@ -13,6 +14,9 @@ for arg in "$@"; do
1314
--dedup-by-email)
1415
DEDUP_BY_EMAIL=1
1516
;;
17+
--no-merges)
18+
MERGES_ARG="--no-merges"
19+
;;
1620
-*)
1721
>&2 echo "unknown argument $arg found"
1822
exit 1
@@ -31,6 +35,12 @@ if [ -n "$DEDUP_BY_EMAIL" ] && [ -n "$SUMMARY_BY_LINE" ]; then
3135
exit 1
3236
fi
3337

38+
if [ -n "$MERGES_ARG" ] && [ -n "$SUMMARY_BY_LINE" ]; then
39+
>&2 echo "--no-merges used with --line is not supported"
40+
exit 1
41+
fi
42+
43+
3444
commit=""
3545
test $# -ne 0 && commit=$*
3646
project=${PWD##*/}
@@ -42,7 +52,7 @@ project=${PWD##*/}
4252
date() {
4353
# the $1 can be empty
4454
# shellcheck disable=SC2086
45-
git log --pretty='format: %ai' $1 | cut -d ' ' -f 2
55+
git log $MERGES_ARG --pretty='format: %ai' $1 | cut -d ' ' -f 2
4656
}
4757

4858
#
@@ -63,7 +73,7 @@ active_days() {
6373

6474
commit_count() {
6575
# shellcheck disable=SC2086
66-
git log --oneline $commit | wc -l | tr -d ' '
76+
git log $MERGES_ARG --oneline $commit | wc -l | tr -d ' '
6777
}
6878

6979
#
@@ -193,9 +203,9 @@ else
193203
if [ -n "$DEDUP_BY_EMAIL" ]; then
194204
# the $commit can be empty
195205
# shellcheck disable=SC2086
196-
git shortlog -n -s -e $commit | dedup_by_email | format_authors
206+
git shortlog $MERGES_ARG -n -s -e $commit | dedup_by_email | format_authors
197207
else
198208
# shellcheck disable=SC2086
199-
git shortlog -n -s $commit | format_authors
209+
git shortlog $MERGES_ARG -n -s $commit | format_authors
200210
fi
201211
fi

etc/git-extras-completion.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ _git-standup() {
322322
_git-summary() {
323323
_arguments '--line[summarize with lines rather than commits]'
324324
_arguments '--dedup-by-email[remove duplicate users by the email address]'
325+
_arguments '--no-merges[exclude merge commits]'
325326
__gitex_commits
326327
}
327328

etc/git-extras.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ complete -c git -x -n '__fish_git_using_command standup' -s n -d 'Limit the numb
170170
# summary
171171
complete -c git -n '__fish_git_using_command summary' -l line -d 'summarize with lines rather than commits'
172172
complete -c git -n '__fish_git_using_command summary' -l dedup-by-email -d 'remove duplicate users by the email address'
173+
complete -c git -n '__fish_git_using_command summary' -l no-merges -d 'exclude merge commits'
173174
# release
174175
complete -c git -x -n '__fish_git_using_command release' -s c -d 'Generates/populates the changelog with all commit message since the last tag'
175176
complete -c git -x -n '__fish_git_using_command release' -s r -d 'The "remote" repository that is destination of a push operation'

man/git-summary.1

Lines changed: 15 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,52 @@
1-
.\" generated with Ronn/v0.7.3
2-
.\" http://github.com/rtomayko/ronn/tree/0.7.3
3-
.
4-
.TH "GIT\-SUMMARY" "1" "July 2021" "" "Git Extras"
5-
.
1+
.\" generated with Ronn-NG/v0.9.1
2+
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
3+
.TH "GIT\-SUMMARY" "1" "August 2021" "" "Git Extras"
64
.SH "NAME"
75
\fBgit\-summary\fR \- Show repository summary
8-
.
96
.SH "SYNOPSIS"
10-
\fBgit\-summary\fR [\-\-line] [\-\-dedup\-by\-email] [<committish or path>]
11-
.
7+
\fBgit\-summary\fR [\-\-dedup\-by\-email] [\-\-no\-merges] [<committish>]
8+
.br
9+
\fBgit\-summary\fR \-\-line [<path>]
1210
.SH "DESCRIPTION"
1311
Shows a summary of the repository\.
14-
.
1512
.SH "OPTIONS"
1613
<committish>
17-
.
1814
.P
1915
Summarize only the range of commits included in the <committish>\.
20-
.
2116
.P
2217
<path>
23-
.
2418
.P
2519
Summarize only the range of files included in the <path>\.
26-
.
2720
.P
2821
\-\-dedup\-by\-email
29-
.
3022
.P
3123
Remove duplicate authors who belong to the same email address\. For example,
32-
.
3324
.IP "" 4
34-
.
3525
.nf
36-
3726
$ git summary
38-
\.\.\.
27+
\|\.\|\.\|\.
3928
133 TJ Holowaychuk 9\.9%
4029
115 Tj Holowaychuk 8\.5%
4130

4231
$ git summary \-\-dedup\-by\-email
43-
\.\.\.
32+
\|\.\|\.\|\.
4433
248 TJ Holowaychuk 18\.4%
45-
.
4634
.fi
47-
.
4835
.IP "" 0
49-
.
5036
.P
51-
This option can not be used together with \fB\-\-line\fR\.
52-
.
37+
\-\-no\-merges
38+
.P
39+
Exclude merge commits\.
5340
.P
5441
\-\-line
55-
.
5642
.P
5743
Summarize with lines other than commits\. When \fB\-\-line\fR is specified, the last argument is treated as <path>\.
58-
.
44+
.P
45+
This option can not be used together with \fB\-\-dedup\-by\-email\fR or \fB\-\-no\-merges\fR\.
5946
.SH "EXAMPLES"
6047
Outputs a repo summary:
61-
.
6248
.IP "" 4
63-
.
6449
.nf
65-
6650
$ git summary
6751

6852
project : express
@@ -89,65 +73,42 @@ authors :
8973
1 ewoudj
9074
1 isaacs
9175
1 Matt Colyer
92-
.
9376
.fi
94-
.
9577
.IP "" 0
96-
.
9778
.P
9879
This command can also take a committish, and will print a summary for the range of commits included in the committish:
99-
.
10080
.IP "" 4
101-
.
10281
.nf
103-
10482
$ git summary v42\.\.
105-
.
10683
.fi
107-
.
10884
.IP "" 0
109-
.
11085
.P
11186
Outputs a repo summary by line:
112-
.
11387
.IP "" 4
114-
.
11588
.nf
116-
11789
$ git summary \-\-line
11890

11991
project : git\-extras
12092
lines : 26820
12193
authors :
122-
\.\.\.
123-
.
94+
\|\.\|\.\|\.
12495
.fi
125-
.
12696
.IP "" 0
127-
.
12897
.P
12998
Filter with the path:
130-
.
13199
.IP "" 4
132-
.
133100
.nf
134-
135101
$ git summary \-\-line bin/
136102

137103
project : git\-extras
138104
lines : 4420
139105
authors :
140-
\.\.\.
141-
.
106+
\|\.\|\.\|\.
142107
.fi
143-
.
144108
.IP "" 0
145-
.
146109
.SH "AUTHOR"
147110
Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR>
148-
.
149111
.SH "REPORTING BUGS"
150112
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
151-
.
152113
.SH "SEE ALSO"
153114
<\fIhttps://github\.com/tj/git\-extras\fR>

man/git-summary.html

Lines changed: 26 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/git-summary.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ git-summary(1) -- Show repository summary
33

44
## SYNOPSIS
55

6-
`git-summary` [--line] [--dedup-by-email] [&lt;committish or path&gt;]
6+
`git-summary` [--dedup-by-email] [--no-merges] [&lt;committish&gt;]
7+
`git-summary` --line [&lt;path&gt;]
78

89
## DESCRIPTION
910

@@ -33,13 +34,17 @@ Shows a summary of the repository.
3334
...
3435
248 TJ Holowaychuk 18.4%
3536

36-
This option can not be used together with `--line`.
37+
--no-merges
38+
39+
Exclude merge commits.
3740

3841
--line
3942

4043
Summarize with lines other than commits.
4144
When `--line` is specified, the last argument is treated as &lt;path&gt;.
4245

46+
This option can not be used together with `--dedup-by-email` or `--no-merges`.
47+
4348
## EXAMPLES
4449

4550
Outputs a repo summary:

0 commit comments

Comments
 (0)