From fae4b8e81baafb2ed54516b1a34515038dce6c2c Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Fri, 6 Oct 2023 17:31:37 -0700 Subject: [PATCH] add git checks for staged and unstaged changes --- chk_tree | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/chk_tree b/chk_tree index 0e975be..61a3e23 100755 --- a/chk_tree +++ b/chk_tree @@ -142,6 +142,25 @@ if [[ -d .git ]]; then EXIT_CODE=13 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 fi + + # verify that there are no uncommitted changes under git + # + GIT_STATUS=$(git status --untracked-files=no --porcelain 2>&1) + if [[ -n $GIT_STATUS ]] || ! diff --quiet --exit-code; then + echo "$0: ERROR: there are unstaged changes" 1>&2 + git status --untracked-files=no --porcelain --short + EXIT_CODE=14 + echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 + fi + + # verify that there are no staged uncommitted changes under git + # + if ! git diff --cached --quiet --exit-code; then + echo "$0: ERROR: there are staged uncommitted changes" 1>&2 + git status --short + EXIT_CODE=15 + echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 + fi fi # collect make buildlist file list @@ -173,7 +192,7 @@ if [[ ${#DISTLIST_ALSO_IN_BUILDLIST[@]} -ne 0 ]]; then # echo "$0: ERROR: distlist files found in buildlist" 1>&2 echo "$0: ERROR: distlist files found in buildlist: ${DISTLIST_ALSO_IN_BUILDLIST[*]}" 1>&2 - EXIT_CODE=14 + EXIT_CODE=16 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 fi @@ -231,7 +250,7 @@ if [[ ${#UNKNOWN_FILE[@]} -ne 0 ]]; then # echo "$0: ERROR: files that are neither built nor distlist are found" 1>&2 echo "$0: ERROR: distlist files found in buildlist: ${UNKNOWN_FILE[*]}" 1>&2 - EXIT_CODE=15 + EXIT_CODE=16 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 fi