Skip to content

Commit d68e3c4

Browse files
committed
break change: git-authors no longer to support open the editor
* test(git-authors): add unit test * doc(git-authors): remove description of opening authors with the default editor
1 parent da79cee commit d68e3c4

File tree

6 files changed

+96
-86
lines changed

6 files changed

+96
-86
lines changed

Commands.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,6 @@ $ git squash HEAD~3 "Work on a feature"
953953
954954
Populates the file matching `authors|contributors -i` with the authors of commits, according to the number of commits per author.
955955
956-
Opens the file in `$EDITOR` when set.
957-
958956
See the ["MAPPING AUTHORS" section](https://git-scm.com/docs/git-shortlog#_mapping_authors) of **git-shortlog**(1) to coalesce together commits by the same person.
959957
960958
Updating AUTHORS file:

bin/git-authors

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
LIST=false
44
NO_EMAIL=false
55
FILE=""
6-
EDITOR=$(git var GIT_EDITOR)
76

87
while [[ $# -gt 0 ]]; do
98
case $1 in
@@ -37,10 +36,10 @@ fi
3736
authors() {
3837
if $NO_EMAIL; then
3938
# email will be used to uniq authors.
40-
git shortlog -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++' \
39+
git shortlog HEAD -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++' \
4140
| awk -F'<' '{gsub(/ +$/, "", $1); print $1}'
4241
else
43-
git shortlog -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++'
42+
git shortlog HEAD -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++'
4443
fi
4544
}
4645

@@ -52,5 +51,4 @@ if $LIST; then
5251
authors
5352
else
5453
authors >> "$FILE"
55-
test -n "$EDITOR" && $EDITOR "$FILE"
5654
fi

man/git-authors.1

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,59 @@
1-
.\" generated with Ronn/v0.7.3
2-
.\" http://github.com/rtomayko/ronn/tree/0.7.3
3-
.
4-
.TH "GIT\-AUTHORS" "1" "October 2017" "" "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\-AUTHORS" "1" "November 2023" "" "Git Extras"
64
.SH "NAME"
75
\fBgit\-authors\fR \- Generate authors report
8-
.
96
.SH "SYNOPSIS"
107
\fBgit\-authors\fR [\-l, \-\-list] [\-\-no\-email]
11-
.
128
.SH "DESCRIPTION"
13-
Populates the file matching \fIauthors|contributors \-i\fR with the authors of commits, according to the number of commits per author\. Opens the file in \fB$EDITOR\fR when set\.
14-
.
9+
.TS
10+
allbox;
11+
Populates the file matching _authors contributors \-i_ with the authors of commits, according to the number of commits per author\.
12+
.TE
1513
.P
1614
See the "MAPPING AUTHORS" section of \fBgit\-shortlog\fR(1) to coalesce together commits by the same person\.
17-
.
1815
.SH "OPTIONS"
1916
\-l, \-\-list
20-
.
2117
.P
2218
Show authors\.
23-
.
2419
.P
2520
\-\-no\-email
26-
.
2721
.P
2822
Don\'t show authors\' email\.
29-
.
3023
.SH "EXAMPLES"
31-
.
32-
.TP
3324
Updating AUTHORS file:
34-
.
35-
.IP
25+
.IP "" 4
26+
.nf
3627
$ git authors
37-
.
38-
.TP
28+
.fi
29+
.IP "" 0
30+
.P
3931
Listing authors:
40-
.
41-
.IP
42-
$ git authors \-\-list
43-
.
4432
.IP "" 4
45-
.
4633
.nf
47-
34+
$ git authors \-\-list
4835
TJ Holowaychuk <tj@vision\-media\.ca>
4936
hemanth\.hm <hemanth\.hm@gmail\.com>
5037
Jonhnny Weslley <jw@jonhnnyweslley\.net>
5138
nickl\- <github@jigsoft\.co\.za>
5239
Leila Muhtasib <muhtasib@gmail\.com>
53-
.
5440
.fi
55-
.
5641
.IP "" 0
57-
58-
.
59-
.TP
42+
.P
6043
Listing authors without email:
61-
.
62-
.IP
63-
$ git authors \-\-list \-\-no\-email
64-
.
6544
.IP "" 4
66-
.
6745
.nf
68-
46+
$ git authors \-\-list \-\-no\-email
6947
TJ Holowaychuk
7048
hemanth\.hm
7149
Jonhnny Weslley
7250
nickl\-
7351
Leila Muhtasib
74-
.
7552
.fi
76-
.
7753
.IP "" 0
78-
79-
.
8054
.SH "AUTHOR"
8155
Written by Titus Wormer <\fItituswormer@gmail\.com\fR>
82-
.
8356
.SH "REPORTING BUGS"
8457
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
85-
.
8658
.SH "SEE ALSO"
8759
<\fIhttps://github\.com/tj/git\-extras\fR>

man/git-authors.html

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

man/git-authors.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ git-authors(1) -- Generate authors report
88
## DESCRIPTION
99

1010
Populates the file matching _authors|contributors -i_ with the authors of commits, according to the number of commits per author.
11-
Opens the file in **$EDITOR** when set.
1211

1312
See the "MAPPING AUTHORS" section of **git-shortlog**(1) to coalesce together commits by the same person.
1413

@@ -24,33 +23,27 @@ git-authors(1) -- Generate authors report
2423

2524
## EXAMPLES
2625

27-
* Updating AUTHORS file:
26+
Updating AUTHORS file:
2827

2928
$ git authors
3029

31-
* Listing authors:
30+
Listing authors:
3231

3332
$ git authors --list
34-
35-
```
3633
TJ Holowaychuk <[email protected]>
3734
hemanth.hm <[email protected]>
3835
Jonhnny Weslley <[email protected]>
3936
4037
Leila Muhtasib <[email protected]>
41-
```
4238

43-
* Listing authors without email:
39+
Listing authors without email:
4440

4541
$ git authors --list --no-email
46-
47-
```
4842
TJ Holowaychuk
4943
hemanth.hm
5044
Jonhnny Weslley
5145
nickl-
5246
Leila Muhtasib
53-
```
5447

5548
## AUTHOR
5649

tests/test_authors.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import os, subprocess
2+
3+
expected_authors_list = "test <[email protected]>\ntestagain <[email protected]>\n"
4+
expected_authors_list_without_email = "test\ntestagain\n"
5+
authors_file = "AUTHORS"
6+
7+
class TestGitAuthors:
8+
def test_init(self, temp_repo):
9+
git = temp_repo.get_repo_git()
10+
tmp_file = temp_repo.get_file(0)
11+
temp_repo.writefile(tmp_file, "A")
12+
git.add(".")
13+
git.commit("-m", "test: add data A")
14+
git.config("--local", "user.name", "testagain")
15+
git.config("--local", "user.email", "[email protected]")
16+
temp_repo.writefile(tmp_file, "B")
17+
git.add(".")
18+
git.commit("-m", "test: add data B")
19+
20+
def test_output_authors_has_email_without_any_parameter(self, temp_repo):
21+
git = temp_repo.get_repo_git()
22+
rs = temp_repo.invoke_extras_command("authors")
23+
with open(authors_file) as f:
24+
content = f.read()
25+
print(content)
26+
print(expected_authors_list)
27+
assert content == expected_authors_list
28+
29+
def test_list_authors_has_email_defaultly(self, temp_repo):
30+
git = temp_repo.get_repo_git()
31+
actual = temp_repo.invoke_extras_command("authors", "--list")
32+
actual = actual.stdout.decode()
33+
assert actual == expected_authors_list
34+
actual = temp_repo.invoke_extras_command("authors", "-l")
35+
actual = actual.stdout.decode()
36+
assert actual == expected_authors_list
37+
38+
def test_list_authors_has_not_email(self, temp_repo):
39+
git = temp_repo.get_repo_git()
40+
actual = temp_repo.invoke_extras_command("authors", "--list", "--no-email")
41+
actual = actual.stdout.decode()
42+
assert actual == expected_authors_list_without_email
43+
actual = temp_repo.invoke_extras_command("authors", "-l", "--no-email")
44+
actual = actual.stdout.decode()
45+
assert actual == expected_authors_list_without_email

0 commit comments

Comments
 (0)