Skip to content

Commit

Permalink
fix: error fetching history for PR branches (#1015)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
jackton1 and github-actions[bot] committed Mar 10, 2023
1 parent 6961203 commit 84ed30e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 51 deletions.
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
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

0 comments on commit 84ed30e

Please sign in to comment.