From 04124efe7560d15e11ea2ba96c0df2989f68f1f4 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 28 Feb 2023 12:47:37 -0700 Subject: [PATCH] feat: pull submodule history for pull request events (#1003) --- .github/workflows/test.yml | 3 +++ diff-sha.sh | 12 ++++++++++-- get-changed-paths.sh | 1 - 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f1c232f739b..54504bb4853 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -342,12 +342,15 @@ jobs: max-parallel: 4 matrix: platform: [ubuntu-latest] + fetch-depth: [0, 1] steps: - name: Checkout to branch uses: actions/checkout@v3 with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} submodules: recursive + fetch-depth: ${{ matrix.fetch-depth }} - name: Run changed-files with submodule id: changed-files diff --git a/diff-sha.sh b/diff-sha.sh index 74cfdedef5e..b4049c3d353 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -75,8 +75,11 @@ if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF ]]; then # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$SOURCE_BRANCH":refs/remotes/origin/"$SOURCE_BRANCH" 1>/dev/null fi - # shellcheck disable=SC2086 - git submodule foreach git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" || true + + if git submodule status &>/dev/null; then + # shellcheck disable=SC2086 + git submodule foreach git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" || true + fi fi echo "::debug::Getting HEAD SHA..." @@ -194,6 +197,11 @@ else git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" 1>/dev/null git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" 1>/dev/null || true fi + + if git submodule status &>/dev/null; then + # shellcheck disable=SC2086 + git submodule foreach git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" || true + fi fi echo "::debug::Getting HEAD SHA..." diff --git a/get-changed-paths.sh b/get-changed-paths.sh index 1d732c17434..a47e9b6537e 100755 --- a/get-changed-paths.sh +++ b/get-changed-paths.sh @@ -93,7 +93,6 @@ function get_diff() { fi done < <(git submodule status --recursive | grep -v "^-" | awk '{print $2}') - if [[ "$filter" == "D" ]]; then while read -r sub; do echo "$sub"