From fca6d1c9793210d09b259199ec14ede8b3f6707b Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sun, 18 Dec 2022 22:54:12 -0700 Subject: [PATCH] chore: code cleanup --- diff-sha.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 5e064a68ef1..9988824db89 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -208,13 +208,15 @@ else else echo "::debug::Fetching remote target branch..." # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$TARGET_BRANCH" 1>/dev/null 2>&1 + git fetch -u --progress $EXTRA_ARGS --depth="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" 1>/dev/null 2>&1 + + git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" 1>/dev/null 2>&1 || true echo "::debug::Fetching remote current branch..." # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null 2>&1 + git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" - PREVIOUS_SHA=$(git merge-base origin/"$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? fi if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then @@ -227,7 +229,7 @@ else 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 origin/"$TARGET_BRANCH") && exit_status=$? || exit_status=$? + 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