From 21cedfcae4d503fa534293cbd88548d605ad72b7 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Fri, 6 Oct 2023 18:04:05 -0700 Subject: [PATCH] improve branch check for chk_tree --- chk_tree | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/chk_tree b/chk_tree index b0353eb..49e3b54 100755 --- a/chk_tree +++ b/chk_tree @@ -166,21 +166,31 @@ if [[ -d .git ]]; then # GIT_MASTER=$(git rev-list --count master) GIT_ORIGIN_MASTER=$(git rev-list --count origin/master) - if [[ $GIT_MASTER -ne $GIT_ORIGIN_MASTER ]]; then - echo "$0: ERROR: master branch is ahead of origin/master" 1>&2 + if [[ $GIT_MASTER -lt $GIT_ORIGIN_MASTER ]]; then + echo "$0: ERROR: master branch is behind of origin/master" 1>&2 git status master EXIT_CODE=16 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 # verify that branch is not ahead of 'origin/HEAD' # GIT_HEAD=$(git rev-list --count 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 git status HEAD - EXIT_CODE=17 + EXIT_CODE=19 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 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: ${DISTLIST_ALSO_IN_BUILDLIST[*]}" 1>&2 - EXIT_CODE=18 + EXIT_CODE=20 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 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: 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 fi