Merge pull request #966 from tfendin/git-standup-implicit-week

Added config git-extras.standup-implicit-week for git standup
This commit is contained in:
罗泽轩 2022-05-09 13:06:33 +08:00 committed by GitHub
commit 458cb9fdad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 4 deletions

View file

@ -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)
@ -77,7 +79,8 @@ 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
@ -85,10 +88,11 @@ while getopts "hgfBd:a:w:m:D:n:L" opt; do
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%%-*}"
@ -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
IMPLICIT_WEEK=$(git config --get git-extras.standup.implicit-week)
if [[ -z "$RANGE_SPECIFIED" ]] && [[ -n "${IMPLICIT_WEEK}" ]]; then
week_start=${IMPLICIT_WEEK%%-*}
week_end=${IMPLICIT_WEEK##*-}
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\"

View file

@ -55,6 +55,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

View file

@ -57,6 +57,7 @@
<a href="#SYNOPSIS">SYNOPSIS</a>
<a href="#DESCRIPTION">DESCRIPTION</a>
<a href="#OPTIONS">OPTIONS</a>
<a href="#GIT-CONFIGS">GIT CONFIGS</a>
<a href="#EXAMPLES">EXAMPLES</a>
<a href="#AUTHOR">AUTHOR</a>
<a href="#REPORTING-BUGS">REPORTING BUGS</a>
@ -143,6 +144,14 @@ When <code>-B</code> is specific, the limitation is applied in the branch level
if each of your 3 repositories have 2 branches, <code>git standup ... -B -n 1</code> will
display 6 commits at most.</p>
<h2 id="GIT-CONFIGS">GIT CONFIGS</h2>
<p>You can configure a implicit -w <var>weekstart-weekend</var>, which is superseded if -w or -d is given on the command line.
Note that the <var>weekstart-weekend</var> must be specified, they don't have any default values as the <code>-w</code> flag has.</p>
<pre><code>$ git config --global git-extras.standup.implicit-week "Mon-Fri"
</code></pre>
<h2 id="EXAMPLES">EXAMPLES</h2>
<p>This shows your commits since yesterday:</p>

View file

@ -69,6 +69,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: