add git checks for staged and unstaged changes

This commit is contained in:
Landon Curt Noll
2023-10-06 17:31:37 -07:00
parent ddf0c8f1f5
commit fae4b8e81b

View File

@@ -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