improve branch check for chk_tree

This commit is contained in:
Landon Curt Noll
2023-10-06 18:04:05 -07:00
parent 4fa137a638
commit 21cedfcae4

View File

@@ -166,21 +166,31 @@ if [[ -d .git ]]; then
# #
GIT_MASTER=$(git rev-list --count master) GIT_MASTER=$(git rev-list --count master)
GIT_ORIGIN_MASTER=$(git rev-list --count origin/master) GIT_ORIGIN_MASTER=$(git rev-list --count origin/master)
if [[ $GIT_MASTER -ne $GIT_ORIGIN_MASTER ]]; then if [[ $GIT_MASTER -lt $GIT_ORIGIN_MASTER ]]; then
echo "$0: ERROR: master branch is ahead of origin/master" 1>&2 echo "$0: ERROR: master branch is behind of origin/master" 1>&2
git status master git status master
EXIT_CODE=16 EXIT_CODE=16
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
elif [[ $GIT_MASTER -gt $GIT_ORIGIN_MASTER ]]; then
echo "$0: ERROR: master branch is ahead of origin/master" 1>&2
git status master
EXIT_CODE=17
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi fi
# verify that branch is not ahead of 'origin/HEAD' # verify that branch is not ahead of 'origin/HEAD'
# #
GIT_HEAD=$(git rev-list --count HEAD) GIT_HEAD=$(git rev-list --count HEAD)
GIT_ORIGIN_HEAD=$(git rev-list --count origin/HEAD) GIT_ORIGIN_HEAD=$(git rev-list --count origin/HEAD)
if [[ $GIT_HEAD -ne $GIT_ORIGIN_HEAD ]]; then if [[ $GIT_HEAD -lt $GIT_ORIGIN_HEAD ]]; then
echo "$0: ERROR: HEAD is behind of origin/HEAD" 1>&2
git status HEAD
EXIT_CODE=18
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
elif [[ $GIT_HEAD -gt $GIT_ORIGIN_HEAD ]]; then
echo "$0: ERROR: HEAD is ahead of origin/HEAD" 1>&2 echo "$0: ERROR: HEAD is ahead of origin/HEAD" 1>&2
git status HEAD git status HEAD
EXIT_CODE=17 EXIT_CODE=19
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi fi
fi fi
@@ -214,7 +224,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" 1>&2
echo "$0: ERROR: distlist files found in buildlist: ${DISTLIST_ALSO_IN_BUILDLIST[*]}" 1>&2 echo "$0: ERROR: distlist files found in buildlist: ${DISTLIST_ALSO_IN_BUILDLIST[*]}" 1>&2
EXIT_CODE=18 EXIT_CODE=20
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi fi
@@ -272,7 +282,7 @@ if [[ ${#UNKNOWN_FILE[@]} -ne 0 ]]; then
# #
echo "$0: ERROR: files that are neither built nor distlist are found" 1>&2 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 echo "$0: ERROR: distlist files found in buildlist: ${UNKNOWN_FILE[*]}" 1>&2
EXIT_CODE=19 EXIT_CODE=21
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi fi