From 083d3f00a1da8e26978a33126d46cece48019413 Mon Sep 17 00:00:00 2001 From: vanpipy Date: Sat, 11 Nov 2023 16:21:30 +0800 Subject: [PATCH] feat(git-authors)!: no longer to support open the editor * BREAKING CHANGE: remove behavior of opening authors with the default editor * test: add unit test --- Commands.md | 2 -- bin/git-authors | 6 ++--- man/git-authors.1 | 58 +++++++++++-------------------------------- man/git-authors.html | 58 +++++++++++++++++++++++-------------------- man/git-authors.md | 13 +++------- tests/test_authors.py | 45 +++++++++++++++++++++++++++++++++ 6 files changed, 96 insertions(+), 86 deletions(-) create mode 100644 tests/test_authors.py diff --git a/Commands.md b/Commands.md index 70f5ce1c3..04c6f2dcd 100644 --- a/Commands.md +++ b/Commands.md @@ -953,8 +953,6 @@ $ git squash HEAD~3 "Work on a feature" Populates the file matching `authors|contributors -i` with the authors of commits, according to the number of commits per author. -Opens the file in `$EDITOR` when set. - 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. Updating AUTHORS file: diff --git a/bin/git-authors b/bin/git-authors index 121e629bc..baa95ee7c 100755 --- a/bin/git-authors +++ b/bin/git-authors @@ -3,7 +3,6 @@ LIST=false NO_EMAIL=false FILE="" -EDITOR=$(git var GIT_EDITOR) while [[ $# -gt 0 ]]; do case $1 in @@ -37,10 +36,10 @@ fi authors() { if $NO_EMAIL; then # email will be used to uniq authors. - git shortlog -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++' \ + git shortlog HEAD -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++' \ | awk -F'<' '{gsub(/ +$/, "", $1); print $1}' else - git shortlog -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++' + git shortlog HEAD -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++' fi } @@ -52,5 +51,4 @@ if $LIST; then authors else authors >> "$FILE" - test -n "$EDITOR" && $EDITOR "$FILE" fi diff --git a/man/git-authors.1 b/man/git-authors.1 index edebfd903..3169dfa5c 100644 --- a/man/git-authors.1 +++ b/man/git-authors.1 @@ -1,87 +1,59 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "GIT\-AUTHORS" "1" "October 2017" "" "Git Extras" -. +.\" generated with Ronn-NG/v0.9.1 +.\" http://github.com/apjanke/ronn-ng/tree/0.9.1 +.TH "GIT\-AUTHORS" "1" "November 2023" "" "Git Extras" .SH "NAME" \fBgit\-authors\fR \- Generate authors report -. .SH "SYNOPSIS" \fBgit\-authors\fR [\-l, \-\-list] [\-\-no\-email] -. .SH "DESCRIPTION" -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\. -. +.TS +allbox; +Populates the file matching _authors contributors \-i_ with the authors of commits, according to the number of commits per author\. +.TE .P See the "MAPPING AUTHORS" section of \fBgit\-shortlog\fR(1) to coalesce together commits by the same person\. -. .SH "OPTIONS" \-l, \-\-list -. .P Show authors\. -. .P \-\-no\-email -. .P Don\'t show authors\' email\. -. .SH "EXAMPLES" -. -.TP Updating AUTHORS file: -. -.IP +.IP "" 4 +.nf $ git authors -. -.TP +.fi +.IP "" 0 +.P Listing authors: -. -.IP -$ git authors \-\-list -. .IP "" 4 -. .nf - +$ git authors \-\-list TJ Holowaychuk hemanth\.hm Jonhnny Weslley nickl\- Leila Muhtasib -. .fi -. .IP "" 0 - -. -.TP +.P Listing authors without email: -. -.IP -$ git authors \-\-list \-\-no\-email -. .IP "" 4 -. .nf - +$ git authors \-\-list \-\-no\-email TJ Holowaychuk hemanth\.hm Jonhnny Weslley nickl\- Leila Muhtasib -. .fi -. .IP "" 0 - -. .SH "AUTHOR" Written by Titus Wormer <\fItituswormer@gmail\.com\fR> -. .SH "REPORTING BUGS" <\fIhttps://github\.com/tj/git\-extras/issues\fR> -. .SH "SEE ALSO" <\fIhttps://github\.com/tj/git\-extras\fR> diff --git a/man/git-authors.html b/man/git-authors.html index 185f3ef91..697fef566 100644 --- a/man/git-authors.html +++ b/man/git-authors.html @@ -1,8 +1,8 @@ - - + + git-authors(1) - Generate authors report