From 745c7ab50026b2cebb5d5c36484e0b4b4e6da3ae Mon Sep 17 00:00:00 2001 From: Tobias Fendin Date: Fri, 29 Apr 2022 11:04:04 +0200 Subject: [PATCH] Improved check if -w or -d was given to git standup --- bin/git-standup | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/git-standup b/bin/git-standup index 787a13a..6ab1774 100755 --- a/bin/git-standup +++ b/bin/git-standup @@ -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##*-}