Skip to content

Commit

Permalink
Merge pull request #974 from tfendin/970-standup-author-date
Browse files Browse the repository at this point in the history
#970 standup added -A flag for author date
  • Loading branch information
spacewander committed Jul 4, 2022
2 parents d597f68 + 48ef95d commit 8166542
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 24 deletions.
32 changes: 27 additions & 5 deletions bin/git-standup
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
usage() {
cat <<EOS
Usage:
git standup [-a <author name>] [-w <weekstart-weekend>|-d <days-ago>] [-m <max-dir-depth>] [-g] [-h] [-f] [-B] [-n <number-of-commits]
git standup [-a <author name>] [-w <weekstart-weekend>|-d <days-ago>] [-m <max-dir-depth>] [-D date-format] [-L] [-h] [-f] [-B] [-n <number-of-commits] [-F <gpg|authordate>]
-a - Specify author to restrict search to, default to current git user.
Use "-a all" if you don't want the restriction.
Expand All @@ -15,10 +15,11 @@ usage() {
-d - Specify the number of days back to include
-D - Specify the date format for "git log" (default: relative)
-h - Display this help screen
-g - Show if commit is GPG signed (G) or not (N)
-f - Fetch the latest commits beforehand
-B - Display the commits in branch groups
-n - Limit the number of commits displayed per group
-F gpg - Show if commit is GPG signed (G) or not (N)
-F authordate - Print author date instead of commit date
Examples:
git standup -a "John Doe" -w "MON-FRI" -m 3
Expand Down Expand Up @@ -64,8 +65,10 @@ fi
set -e

RANGE_SPECIFIED=
COMMIT_DATE_FORMAT=%cd
USE_GPG_FORMAT=no

while getopts "hgfBd:a:w:m:D:n:L" opt; do
while getopts "hgfF:Bd:a:w:m:D:n:L" opt; do
case $opt in
h)
usage
Expand Down Expand Up @@ -124,14 +127,30 @@ while getopts "hgfBd:a:w:m:D:n:L" opt; do
GIT_DATE_FORMAT=${OPTARG}
;;
g)
GIT_PRETTY_FORMAT="%C(yellow)gpg: %G?%Creset"
warn "-g option is deprecated, use '-F gpg' instead"
USE_GPG_FORMAT=yes
;;
B)
GROUP_BY_BRANCHES=true
;;
n)
MAX_COMMIT_NUM=${OPTARG}
;;
F)
case $OPTARG in
gpg)
USE_GPG_FORMAT=yes
;;
authordate)
COMMIT_DATE_FORMAT=%ad
;;
*)
warn "Invalid argument for -F: $OPTARG"
usage
exit 1
;;
esac
;;
\?)
usage
exit 1
Expand All @@ -155,8 +174,11 @@ fi
AUTHOR=${AUTHOR:="$(git config user.name)"}
FETCH_LAST_COMMIT=${FETCH_LAST_COMMIT:=false}
MAXDEPTH=${MAXDEPTH:=2}
GIT_PRETTY_FORMAT="%Cred%h%Creset - %s %Cgreen(%cd) %C(bold blue)<%an>%Creset $GIT_PRETTY_FORMAT"
GIT_PRETTY_FORMAT="%Cred%h%Creset - %s %Cgreen(${COMMIT_DATE_FORMAT}) %C(bold blue)<%an>%Creset"
GIT_DATE_FORMAT=${GIT_DATE_FORMAT:=relative}
if [[ "$USE_GPG_FORMAT" == 'yes' ]]; then
GIT_PRETTY_FORMAT="$GIT_PRETTY_FORMAT %C(yellow)gpg: %G?%Creset"
fi

# Handle config of implicit week
IMPLICIT_WEEK=$(git config --get git-extras.standup.implicit-week)
Expand Down
19 changes: 12 additions & 7 deletions man/git-standup.1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "GIT\-STANDUP" "1" "April 2022" "" "Git Extras"
.TH "GIT\-STANDUP" "1" "July 2022" "" "Git Extras"
.SH "NAME"
\fBgit\-standup\fR \- Recall the commit history
.SH "SYNOPSIS"
\fBgit\-standup\fR [\-a author] [\-w \fIweekstart\-weekend\fR|\-d \fIdays\-ago\fR] [\-m depth] [\-D date format] [\-g] [\-L] [\-f] [\-B] [\-n number of commits]
\fBgit\-standup\fR [\-a author] [\-w \fIweekstart\-weekend\fR|\-d \fIdays\-ago\fR] [\-m depth] [\-D date format] [\-L] [\-f] [\-B] [\-n number of commits] [\-F \fIgpg|authordate\fR]
.br
\fBgit\-standup\fR \-h
.SH "DESCRIPTION"
Expand All @@ -28,7 +28,7 @@ The start of commit history\. Defaults to 1, means "1 days ago"\.
.P
\-w \fIweekstart\-weekend\fR
.P
Limit the search range to weekdays\. If \fIweekstart\fR and/or \fIweekend\fR are missing they default to Mon and Fri\. If the current day is \fIweekstart\fR commits made on \fIweekend\fR will be included\. I\.e\. calling \fBgit standup \-w \-\fR on a Monday will include commits made on the last Friday\.
Limit the search range to weekdays\. If \fIweekstart\fR and/or \fIweekend\fR are missing they default to Mon and Fri\. If the current day is \fIweekstart\fR, commits made on \fIweekend\fR will be included\. I\.e\. calling \fBgit standup \-w \-\fR on a Monday will include commits made on the last Friday\.
.P
\-D relative
.P
Expand All @@ -38,10 +38,6 @@ The date format displayed in commit history\. Defaults to "relative"\.
.P
Display help message\.
.P
\-g
.P
Display if commit is GPG signed (G) or not (N) in commit message\.
.P
\-f
.P
Fetch the latest commits before showing commit history\.
Expand All @@ -55,6 +51,15 @@ Display the commits in branch groups\.
\-n number\-of\-commits
.P
Limit the number of commits displayed per group\. By default, the limitation is applied in the repository level\. For example, if you have 3 repositories under the current directory, \fBgit standup \|\.\|\.\|\. \-n 1\fR will show you 3 commits at most\. When \fB\-B\fR is specific, the limitation is applied in the branch level\. For instance, if each of your 3 repositories have 2 branches, \fBgit standup \|\.\|\.\|\. \-B \-n 1\fR will display 6 commits at most\.
.P
\-F \fIgpg|authordate\fR
.P
Change how the commits are formatted\. Takes an argument, can be specified multiple times\.
.IP "\[ci]" 4
\fB\-F gpg\fR: Display if commit is GPG signed (G) or not (N)\.
.IP "\[ci]" 4
\fB\-F authordate\fR: Print the author date instead of the commit date\.
.IP "" 0
.SH "GIT CONFIGS"
You can configure a implicit \-w \fIweekstart\-weekend\fR, which is superseded if \-w or \-d is given on the command line\. Note that the \fIweekstart\-weekend\fR must be specified, they don\'t have any default values as the \fB\-w\fR flag has\.
.IP "" 4
Expand Down
21 changes: 14 additions & 7 deletions man/git-standup.html

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

13 changes: 8 additions & 5 deletions man/git-standup.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ git-standup(1) -- Recall the commit history

## SYNOPSIS

`git-standup` [-a author] [-w <weekstart-weekend>|-d <days-ago>] [-m depth] [-D date format] [-g] [-L] [-f] [-B] [-n number of commits]
`git-standup` [-a author] [-w <weekstart-weekend>|-d <days-ago>] [-m depth] [-D date format] [-L] [-f] [-B] [-n number of commits] [-F <gpg|authordate>]
`git-standup` -h

## DESCRIPTION
Expand Down Expand Up @@ -44,10 +44,6 @@ The date format displayed in commit history. Defaults to "relative".

Display help message.

-g

Display if commit is GPG signed (G) or not (N) in commit message.

-f

Fetch the latest commits before showing commit history.
Expand All @@ -69,6 +65,13 @@ When `-B` is specific, the limitation is applied in the branch level. For insta
if each of your 3 repositories have 2 branches, `git standup ... -B -n 1` will
display 6 commits at most.

-F <gpg|authordate>

Change how the commits are formatted. Takes an argument, can be specified multiple times.

* `-F gpg`: Display if commit is GPG signed (G) or not (N).
* `-F authordate`: Print the author date instead of the commit date.

## GIT CONFIGS

You can configure a implicit -w <weekstart-weekend>, which is superseded if -w or -d is given on the command line.
Expand Down

0 comments on commit 8166542

Please sign in to comment.