From 349b9cd59684c6136cd3c51c6740e67916011ebf Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 19 Dec 2022 01:12:13 -0700 Subject: [PATCH] chore: code cleanup (#887) Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com> --- diff-sha.sh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 5e064a68ef1..f825c0465ae 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -157,6 +157,8 @@ else fi echo "Fetching remote refs..." + # shellcheck disable=SC2086 + git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null 2>&1 echo "::debug::Getting HEAD SHA..." if [[ -n "$INPUT_UNTIL" ]]; then @@ -168,9 +170,6 @@ else exit 1 fi else - # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" 1>/dev/null 2>&1 - if [[ -z $INPUT_SHA ]]; then CURRENT_SHA=$(git rev-list -n 1 HEAD) && exit_status=$? || exit_status=$? else @@ -197,9 +196,6 @@ else if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then echo "::debug::Fetching remote current branch..." - # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" 1>/dev/null 2>&1 - PREVIOUS_SHA=$GITHUB_EVENT_BEFORE if ! git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1; then @@ -208,13 +204,11 @@ 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 - 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 branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" 1>/dev/null 2>&1 || true - 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 +221,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