Skip to content

Commit 458cb9f

Browse files
authored
Merge pull request #966 from tfendin/git-standup-implicit-week
Added config git-extras.standup-implicit-week for git standup
2 parents 12b2741 + 0701c9e commit 458cb9f

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

bin/git-standup

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ fi
6363
# which may fail on systems lacking tput or terminfo
6464
set -e
6565

66+
RANGE_SPECIFIED=
67+
6668
while getopts "hgfBd:a:w:m:D:n:L" opt; do
6769
case $opt in
6870
h)
@@ -77,18 +79,20 @@ while getopts "hgfBd:a:w:m:D:n:L" opt; do
7779
fi
7880
;;
7981
d)
80-
test -n "$SINCE" && warn "-d option is conflict with -w"
82+
test -n "$RANGE_SPECIFIED" && warn "-d option is conflict with -w"
83+
RANGE_SPECIFIED=yes
8184
if [ "$OPTARG" -lt 1 ]; then
8285
>&2 echo "Specify days less than one is invalid"
8386
exit 1
8487
fi
8588
SINCE="$OPTARG days ago"
8689
;;
8790
w)
88-
if [ -n "$SINCE" ]; then
91+
if [ -n "$RANGE_SPECIFIED" ]; then
8992
warn "-w option is conflict with -d"
9093
continue
9194
fi
95+
RANGE_SPECIFIED=yes
9296

9397
week_range=${OPTARG}
9498
week_start="${week_range%%-*}"
@@ -149,13 +153,26 @@ if [[ $# -gt 0 ]]; then
149153
fi
150154

151155
AUTHOR=${AUTHOR:="$(git config user.name)"}
152-
SINCE=${SINCE:=yesterday}
153-
UNTIL=${UNTIL:=today}
154156
FETCH_LAST_COMMIT=${FETCH_LAST_COMMIT:=false}
155157
MAXDEPTH=${MAXDEPTH:=2}
156158
GIT_PRETTY_FORMAT="%Cred%h%Creset - %s %Cgreen(%cd) %C(bold blue)<%an>%Creset $GIT_PRETTY_FORMAT"
157159
GIT_DATE_FORMAT=${GIT_DATE_FORMAT:=relative}
158160

161+
# Handle config of implicit week
162+
IMPLICIT_WEEK=$(git config --get git-extras.standup.implicit-week)
163+
if [[ -z "$RANGE_SPECIFIED" ]] && [[ -n "${IMPLICIT_WEEK}" ]]; then
164+
week_start=${IMPLICIT_WEEK%%-*}
165+
week_end=${IMPLICIT_WEEK##*-}
166+
shopt -s nocasematch
167+
if [[ "$week_start" == "$(LC_ALL=C date +%a)" ]]; then
168+
SINCE="last $week_end"
169+
fi
170+
UNTIL=today
171+
else
172+
SINCE=${SINCE:=yesterday}
173+
UNTIL=${UNTIL:=today}
174+
fi
175+
159176
GIT_LOG_COMMAND="git --no-pager log \
160177
--no-merges
161178
--since \"$SINCE\"

man/git-standup.1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ Display the commits in branch groups\.
5555
\-n number\-of\-commits
5656
.P
5757
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\.
58+
.SH "GIT CONFIGS"
59+
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\.
60+
.IP "" 4
61+
.nf
62+
$ git config \-\-global git\-extras\.standup\.implicit\-week "Mon\-Fri"
63+
.fi
64+
.IP "" 0
5865
.SH "EXAMPLES"
5966
This shows your commits since yesterday:
6067
.IP "" 4

man/git-standup.html

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

man/git-standup.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ When `-B` is specific, the limitation is applied in the branch level. For insta
6969
if each of your 3 repositories have 2 branches, `git standup ... -B -n 1` will
7070
display 6 commits at most.
7171

72+
## GIT CONFIGS
73+
74+
You can configure a implicit -w <weekstart-weekend>, which is superseded if -w or -d is given on the command line.
75+
Note that the <weekstart-weekend> must be specified, they don't have any default values as the `-w` flag has.
76+
77+
$ git config --global git-extras.standup.implicit-week "Mon-Fri"
78+
7279
## EXAMPLES
7380

7481
This shows your commits since yesterday:

0 commit comments

Comments
 (0)