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: error fetching history for PR branches #1015

Merged
merged 5 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
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
56 changes: 10 additions & 46 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ on:
branches:
- "**"
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main
pull_request_review:
Expand All @@ -28,12 +24,7 @@ jobs:

test-multiple-repositories:
name: Test with multiple repositories
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
max-parallel: 2
matrix:
platform: [ubuntu-latest]
runs-on: ubuntu-latest
steps:
- name: Checkout into dir1
uses: actions/checkout@v3
Expand Down Expand Up @@ -84,13 +75,8 @@ jobs:

test-using-since-and-until:
name: Test changed-files using since and until
runs-on: ${{ matrix.platform }}
runs-on: ubuntu-latest
if: github.event_name == 'push'
strategy:
fail-fast: false
max-parallel: 2
matrix:
platform: [ubuntu-latest]

steps:
- name: Checkout to branch
Expand Down Expand Up @@ -140,12 +126,7 @@ jobs:

test-similar-base-and-commit-sha:
name: Test changed-files similar base and commit sha
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
platform: [ubuntu-latest]
runs-on: ubuntu-latest

steps:
- name: Checkout to branch
Expand Down Expand Up @@ -175,12 +156,7 @@ jobs:

test-unset-github-output-env:
name: Test unset GITHUB_OUTPUT env
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
platform: [ubuntu-latest]
runs-on: ubuntu-latest

steps:
- name: Checkout to branch
Expand All @@ -203,12 +179,11 @@ jobs:

test-limited-commit-history:
name: Test changed-files with limited commit history
runs-on: ${{ matrix.platform }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 4
matrix:
platform: [ubuntu-latest]
fetch-depth: [1, 2]
input-fetch_depth: [1, 50]

Expand All @@ -232,12 +207,7 @@ jobs:

test-non-existent-base-sha:
name: Test changed-files non existent base sha
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
platform: [ubuntu-latest]
runs-on: ubuntu-latest

steps:
- name: Checkout to branch
Expand Down Expand Up @@ -284,12 +254,7 @@ jobs:

test-non-existent-sha:
name: Test changed-files non existent sha
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
platform: [ubuntu-latest]
runs-on: ubuntu-latest

steps:
- name: Checkout to branch
Expand Down Expand Up @@ -336,13 +301,12 @@ jobs:

test-submodules:
name: Test changed-files with submodule
runs-on: ${{ matrix.platform }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 4
matrix:
platform: [ubuntu-latest]
fetch-depth: [0, 1]
fetch-depth: [0, 1, 2]

steps:
- name: Checkout to branch
Expand Down Expand Up @@ -380,7 +344,7 @@ jobs:
max-parallel: 4
matrix:
platform: [ubuntu-latest, ubuntu-22.04, windows-latest, macos-latest, macos-11, windows-2022]
fetch-depth: [0, 1]
fetch-depth: [0, 1, 2]

steps:
- name: Checkout
Expand Down
11 changes: 6 additions & 5 deletions diff-sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,14 @@ else

if [[ "$IS_SHALLOW" == "true" ]]; then
echo "Fetching remote refs..."

if [[ "$GITHUB_EVENT_HEAD_REPO_FORK" != "true" ]]; then
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_PULL_REQUEST_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null
# shellcheck disable=SC2086
if git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_PULL_REQUEST_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null; then
jackton1 marked this conversation as resolved.
Show resolved Hide resolved
echo "First fetch succeeded"
else
echo "First fetch failed, falling back to second fetch"
# 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
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$CURRENT_BRANCH"*:refs/remotes/origin/"$CURRENT_BRANCH"* 1>/dev/null || true
fi

if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" != "true" ]]; then
Expand Down