diff --git a/.github/workflows/check-base-branch.yml b/.github/workflows/check-base-branch.yml index 1c16ff4..29a8efa 100644 --- a/.github/workflows/check-base-branch.yml +++ b/.github/workflows/check-base-branch.yml @@ -20,20 +20,15 @@ jobs: CURRENT_BRANCH=${{ github.head_ref }} TARGET_BRANCH="${{ github.event.pull_request.base.ref }}" - echo $CURRENT_BRANCH - echo $TARGET_BRANCH - - COMMON_ANCESTOR=$(git merge-base origin/$CURRENT_BRANCH origin/$TARGET_BRANCH) COMMITS_BEHIND=$(git rev-list --count origin/$TARGET_BRANCH ^$COMMON_ANCESTOR) - echo $COMMITS_BEHIND - - if [ -n "$COMMITS_BEHIND" ]; then - echo "Your branch is behind the target branch. The following commits are missing:" - echo "$COMMITS_BEHIND" - - exit 1 + if [ "$COMMITS_BEHIND" -eq 0 ]; then + echo "Your branch is up-to-date with the target branch." + elif [ "$COMMITS_BEHIND" -eq 1 ]; then + echo "Your branch is 1 commit behind the target branch." + exit 1 else - echo "Your branch is up to date with the target branch." + echo "Your branch is $COMMITS_BEHIND commits behind the target branch." + exit 1 fi \ No newline at end of file