Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
chrabyrd committed Apr 18, 2024
1 parent 113a76e commit d52b531
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/check-base-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d52b531

Please sign in to comment.