From 62aa91f221d104d4d384f7802bf755cc70e21855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=B3=BD=E8=BD=A9?= Date: Thu, 6 Oct 2022 13:55:45 +0800 Subject: [PATCH] git standup: work as expected when no configured (#996) --- bin/git-standup | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/git-standup b/bin/git-standup index 5a3213e..2a6e273 100755 --- a/bin/git-standup +++ b/bin/git-standup @@ -171,7 +171,12 @@ if [[ $# -gt 0 ]]; then UNTIL=$3 fi -AUTHOR=${AUTHOR:="$(git config user.name)"} +AUTHOR=${AUTHOR:="$(git config user.name || echo '')"} +if [ -z "${AUTHOR}" ]; then + warn "please configure an author with 'git config user.name' or specify an author via '-a'" + exit 1 +fi + FETCH_LAST_COMMIT=${FETCH_LAST_COMMIT:=false} MAXDEPTH=${MAXDEPTH:=2} GIT_PRETTY_FORMAT="%Cred%h%Creset - %s %Cgreen(${COMMIT_DATE_FORMAT}) %C(bold blue)<%an>%Creset" @@ -181,7 +186,7 @@ if [[ "$USE_GPG_FORMAT" == 'yes' ]]; then fi # Handle config of implicit week -IMPLICIT_WEEK=$(git config --get git-extras.standup.implicit-week) +IMPLICIT_WEEK=$(git config --get git-extras.standup.implicit-week || echo '') if [[ -z "$RANGE_SPECIFIED" ]] && [[ -n "${IMPLICIT_WEEK}" ]]; then week_start=${IMPLICIT_WEEK%%-*} week_end=${IMPLICIT_WEEK##*-}