Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added config git-extras.standup-implicit-week for git standup #966

Merged
merged 5 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions bin/git-standup
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ fi
# which may fail on systems lacking tput or terminfo
set -e

RANGE_SPECIFIED=

while getopts "hgfBd:a:w:m:D:n:L" opt; do
case $opt in
h)
Expand All @@ -77,18 +79,20 @@ while getopts "hgfBd:a:w:m:D:n:L" opt; do
fi
;;
d)
test -n "$SINCE" && warn "-d option is conflict with -w"
test -n "$RANGE_SPECIFIED" && warn "-d option is conflict with -w"
RANGE_SPECIFIED=yes
if [ "$OPTARG" -lt 1 ]; then
>&2 echo "Specify days less than one is invalid"
exit 1
fi
SINCE="$OPTARG days ago"
;;
w)
if [ -n "$SINCE" ]; then
if [ -n "$RANGE_SPECIFIED" ]; then
warn "-w option is conflict with -d"
continue
fi
RANGE_SPECIFIED=yes

week_range=${OPTARG}
week_start="${week_range%%-*}"
Expand Down Expand Up @@ -149,13 +153,26 @@ if [[ $# -gt 0 ]]; then
fi

AUTHOR=${AUTHOR:="$(git config user.name)"}
SINCE=${SINCE:=yesterday}
UNTIL=${UNTIL:=today}
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_DATE_FORMAT=${GIT_DATE_FORMAT:=relative}

# Handle config of implicit week
if [[ -z "$RANGE_SPECIFIED" ]] && [[ -n "$(git config --get git-extras.standup.implicit-week)" ]]; then
week_range=$(git config --get git-extras.standup.implicit-week)
week_start=${week_range%%-*}
week_end=${week_range##*-}
shopt -s nocasematch
if [[ "$week_start" == "$(LC_ALL=C date +%a)" ]]; then
SINCE="last $week_end"
fi
UNTIL=today
else
SINCE=${SINCE:=yesterday}
UNTIL=${UNTIL:=today}
fi

GIT_LOG_COMMAND="git --no-pager log \
--no-merges
--since \"$SINCE\"
Expand Down
9 changes: 8 additions & 1 deletion man/git-standup.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "GIT\-STANDUP" "1" "August 2021" "" "Git Extras"
.TH "GIT\-STANDUP" "1" "April 2022" "" "Git Extras"
.SH "NAME"
\fBgit\-standup\fR \- Recall the commit history
.SH "SYNOPSIS"
Expand Down Expand Up @@ -51,6 +51,13 @@ 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\.
.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
.nf
$ git config \-\-global git\-extras\.standup\.implicit\-week "Mon\-Fri"
.fi
.IP "" 0
.SH "EXAMPLES"
This shows your commits since yesterday:
.IP "" 4
Expand Down
11 changes: 10 additions & 1 deletion man/git-standup.html

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

7 changes: 7 additions & 0 deletions man/git-standup.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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.

## GIT CONFIGS

You can configure a implicit -w <weekstart-weekend>, which is superseded if -w or -d is given on the command line.
Note that the <weekstart-weekend> must be specified, they don't have any default values as the `-w` flag has.

$ git config --global git-extras.standup.implicit-week "Mon-Fri"

## EXAMPLES

This shows your commits since yesterday:
Expand Down