diff --git a/diff-sha.sh b/diff-sha.sh index 361ec67d..ccb792dc 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -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" @@ -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