Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bug with fetching history #989

Merged
merged 5 commits into from Feb 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions diff-sha.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -euo pipefail
set -euxo pipefail

INITIAL_COMMIT="false"
GITHUB_OUTPUT=${GITHUB_OUTPUT:-""}
Expand Down Expand Up @@ -57,7 +57,7 @@ if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF ]]; then
TARGET_BRANCH=$GITHUB_REFNAME
CURRENT_BRANCH=$TARGET_BRANCH

if [[ -f .git/shallow ]]; then
if $(git rev-parse --is-shallow-repository); then
echo "Fetching remote refs..."
# 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
Expand Down Expand Up @@ -162,7 +162,7 @@ else
TARGET_BRANCH=$CURRENT_BRANCH
fi

if [[ -f .git/shallow ]]; then
if $(git rev-parse --is-shallow-repository); then
echo "Fetching remote refs..."
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_PULL_REQUEST_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null
Expand Down Expand Up @@ -213,7 +213,7 @@ else
else
PREVIOUS_SHA=$(git rev-parse origin/"$TARGET_BRANCH") && exit_status=$? || exit_status=$?

if [[ -f .git/shallow ]]; then
if $(git rev-parse --is-shallow-repository); then
# check if the merge base is in the local history
if ! git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" 1>/dev/null 2>&1; then
echo "::debug::Merge base is not in the local history, fetching remote target branch..."
Expand Down