Skip to content

Commit

Permalink
feat: improve error handling (#1068)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Apr 4, 2023
1 parent 3bac490 commit 5e2d64b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions diff-sha.sh
Expand Up @@ -70,10 +70,10 @@ if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF ]]; then
echo "Fetching remote refs..."
if [[ "$IS_TAG" == "false" ]]; then
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$CURRENT_BRANCH":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$CURRENT_BRANCH":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null || true
elif [[ "$SOURCE_BRANCH" != "" ]]; then
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$SOURCE_BRANCH":refs/remotes/origin/"$SOURCE_BRANCH" 1>/dev/null
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$SOURCE_BRANCH":refs/remotes/origin/"$SOURCE_BRANCH" 1>/dev/null || true
fi

if git submodule status &>/dev/null; then
Expand Down Expand Up @@ -260,8 +260,14 @@ else
if git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" 1>/dev/null 2>&1; then
break
fi

echo "::debug::Merge base is not in the local history, fetching remote target branch again..."
echo "::debug::Attempt $i/10"

if [[ $i -eq 10 ]]; then
echo "::error::Unable to find the merge base between $PREVIOUS_SHA and $CURRENT_SHA"
exit 1
fi
done
fi
fi
Expand Down

0 comments on commit 5e2d64b

Please sign in to comment.