Improved check if -w or -d was given to git standup

This commit is contained in:
Tobias Fendin 2022-04-29 11:04:04 +02:00
parent 7cb5c55e13
commit 745c7ab500

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%%-*}"
@ -155,7 +159,7 @@ GIT_PRETTY_FORMAT="%Cred%h%Creset - %s %Cgreen(%cd) %C(bold blue)<%an>%Creset $G
GIT_DATE_FORMAT=${GIT_DATE_FORMAT:=relative}
# Handle config of implicit week
if [[ -z "$SINCE" ]] && [[ -z "$UNTIL" ]] && [[ -n "$(git config --get git-extras.standup.implicit-week)" ]]; then
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##*-}