Skip to content

Commit

Permalink
fix: error overriding the base sha (#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Jan 5, 2023
1 parent ebf889a commit dc4c7d5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions diff-sha.sh
Expand Up @@ -215,21 +215,16 @@ else
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
fi

if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
PREVIOUS_SHA=$(git rev-parse "$TARGET_BRANCH") && exit_status=$? || exit_status=$?
DIFF=".."
fi

echo "::debug::Previous SHA: $PREVIOUS_SHA"
else
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
fi

if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
PREVIOUS_SHA=$(git rev-parse "$TARGET_BRANCH") && exit_status=$? || exit_status=$?
DIFF=".."

if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
echo "::error::Unable find a diff between $PREVIOUS_SHA and $CURRENT_SHA"
exit 1
fi
fi

echo "::debug::Target branch: $TARGET_BRANCH"
echo "::debug::Current branch: $CURRENT_BRANCH"

Expand All @@ -241,6 +236,11 @@ else
echo "::error::Please verify that the previous sha is valid, and increase the fetch_depth to a number higher than $INPUT_FETCH_DEPTH."
exit 1
fi

if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
echo "::error::Unable find a diff between $PREVIOUS_SHA and $CURRENT_SHA"
exit 1
fi
fi

if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" && "$INITIAL_COMMIT" == "false" ]]; then
Expand Down

0 comments on commit dc4c7d5

Please sign in to comment.