diff --git a/.changeset/patch-optimize-safe-output-checkout.md b/.changeset/patch-optimize-safe-output-checkout.md new file mode 100644 index 0000000000..874154fb84 --- /dev/null +++ b/.changeset/patch-optimize-safe-output-checkout.md @@ -0,0 +1,11 @@ +--- +"gh-aw": patch +--- + +Optimize safe output checkout to use shallow fetch and targeted branch fetching + +Safe output jobs for `create-pull-request` and `push-to-pull-request-branch` used +full repository checkouts (`fetch-depth: 0`). This change documents the optimization +to use shallow clones (`fetch-depth: 1`) and explicit branch fetches to reduce +network transfer and clone time for large repositories. + diff --git a/.changeset/patch-shallow-checkout-safe-output.md b/.changeset/patch-shallow-checkout-safe-output.md new file mode 100644 index 0000000000..4bb6b33086 --- /dev/null +++ b/.changeset/patch-shallow-checkout-safe-output.md @@ -0,0 +1,10 @@ +--- +"gh-aw": patch +--- + +Optimize safe output jobs to use shallow repository checkouts and targeted +branch fetching for `create-pull-request` and +`push-to-pull-request-branch` safe output jobs. This reduces network transfer and +clone time for large repositories by using `fetch-depth: 1` and fetching only the +required branch. + diff --git a/.github/workflows/changeset.lock.yml b/.github/workflows/changeset.lock.yml index 30eced9bd5..9ea1fd770a 100644 --- a/.github/workflows/changeset.lock.yml +++ b/.github/workflows/changeset.lock.yml @@ -8832,7 +8832,7 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'push_to_pull_request_branch')) env: @@ -9017,7 +9017,7 @@ jobs: const { data: pullRequest } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: pullNumber + pull_number: pullNumber, }); branchName = pullRequest.head.ref; prTitle = pullRequest.title || ""; @@ -9053,9 +9053,10 @@ jobs: const hasChanges = !isEmpty; core.info(`Switching to branch: ${branchName}`); try { - await exec.exec("git fetch origin"); + core.info(`Fetching branch: ${branchName}`); + await exec.exec(`git fetch origin ${branchName}:refs/remotes/origin/${branchName}`); } catch (fetchError) { - core.setFailed(`Failed to fetch from origin: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); + core.setFailed(`Failed to fetch branch ${branchName}: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); return; } try { diff --git a/.github/workflows/ci-coach.lock.yml b/.github/workflows/ci-coach.lock.yml index a38f5d3297..6a4f886ec5 100644 --- a/.github/workflows/ci-coach.lock.yml +++ b/.github/workflows/ci-coach.lock.yml @@ -7573,7 +7573,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -7846,8 +7846,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/cloclo.lock.yml b/.github/workflows/cloclo.lock.yml index 5d90241101..61ef015aa1 100644 --- a/.github/workflows/cloclo.lock.yml +++ b/.github/workflows/cloclo.lock.yml @@ -8397,7 +8397,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -8673,8 +8673,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/craft.lock.yml b/.github/workflows/craft.lock.yml index 4792b06926..a61877f6fe 100644 --- a/.github/workflows/craft.lock.yml +++ b/.github/workflows/craft.lock.yml @@ -8866,7 +8866,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'push_to_pull_request_branch')) env: @@ -9050,7 +9050,7 @@ jobs: const { data: pullRequest } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: pullNumber + pull_number: pullNumber, }); branchName = pullRequest.head.ref; prTitle = pullRequest.title || ""; @@ -9086,9 +9086,10 @@ jobs: const hasChanges = !isEmpty; core.info(`Switching to branch: ${branchName}`); try { - await exec.exec("git fetch origin"); + core.info(`Fetching branch: ${branchName}`); + await exec.exec(`git fetch origin ${branchName}:refs/remotes/origin/${branchName}`); } catch (fetchError) { - core.setFailed(`Failed to fetch from origin: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); + core.setFailed(`Failed to fetch branch ${branchName}: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); return; } try { diff --git a/.github/workflows/daily-doc-updater.lock.yml b/.github/workflows/daily-doc-updater.lock.yml index 3d5803aa28..953d9291b2 100644 --- a/.github/workflows/daily-doc-updater.lock.yml +++ b/.github/workflows/daily-doc-updater.lock.yml @@ -6560,7 +6560,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -6834,8 +6834,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/daily-workflow-updater.lock.yml b/.github/workflows/daily-workflow-updater.lock.yml index a4971c33fa..3a41f1c877 100644 --- a/.github/workflows/daily-workflow-updater.lock.yml +++ b/.github/workflows/daily-workflow-updater.lock.yml @@ -6830,7 +6830,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -7104,8 +7104,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/developer-docs-consolidator.lock.yml b/.github/workflows/developer-docs-consolidator.lock.yml index ee52fb9124..41de4d0b42 100644 --- a/.github/workflows/developer-docs-consolidator.lock.yml +++ b/.github/workflows/developer-docs-consolidator.lock.yml @@ -8166,7 +8166,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -8440,8 +8440,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/dictation-prompt.lock.yml b/.github/workflows/dictation-prompt.lock.yml index d9a94b1606..21bc06216d 100644 --- a/.github/workflows/dictation-prompt.lock.yml +++ b/.github/workflows/dictation-prompt.lock.yml @@ -6725,7 +6725,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -6999,8 +6999,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/github-mcp-tools-report.lock.yml b/.github/workflows/github-mcp-tools-report.lock.yml index 05b6bbc409..5cb0a8accf 100644 --- a/.github/workflows/github-mcp-tools-report.lock.yml +++ b/.github/workflows/github-mcp-tools-report.lock.yml @@ -7977,7 +7977,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -8251,8 +8251,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/glossary-maintainer.lock.yml b/.github/workflows/glossary-maintainer.lock.yml index 7f64e063c7..5ae34d1353 100644 --- a/.github/workflows/glossary-maintainer.lock.yml +++ b/.github/workflows/glossary-maintainer.lock.yml @@ -7418,7 +7418,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -7692,8 +7692,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/go-logger.lock.yml b/.github/workflows/go-logger.lock.yml index a19caf300c..88a7522de5 100644 --- a/.github/workflows/go-logger.lock.yml +++ b/.github/workflows/go-logger.lock.yml @@ -6634,7 +6634,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -6908,8 +6908,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/hourly-ci-cleaner.lock.yml b/.github/workflows/hourly-ci-cleaner.lock.yml index b0e5bacd54..526e668513 100644 --- a/.github/workflows/hourly-ci-cleaner.lock.yml +++ b/.github/workflows/hourly-ci-cleaner.lock.yml @@ -7056,7 +7056,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -7329,8 +7329,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/incident-response.lock.yml b/.github/workflows/incident-response.lock.yml index 09d992061c..e53aad05db 100644 --- a/.github/workflows/incident-response.lock.yml +++ b/.github/workflows/incident-response.lock.yml @@ -9271,7 +9271,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -9544,8 +9544,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/instructions-janitor.lock.yml b/.github/workflows/instructions-janitor.lock.yml index 540b25fd7c..eaa19d9864 100644 --- a/.github/workflows/instructions-janitor.lock.yml +++ b/.github/workflows/instructions-janitor.lock.yml @@ -6514,7 +6514,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -6788,8 +6788,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/jsweep.lock.yml b/.github/workflows/jsweep.lock.yml index 8ad4c0b71c..0a54dfec30 100644 --- a/.github/workflows/jsweep.lock.yml +++ b/.github/workflows/jsweep.lock.yml @@ -6928,7 +6928,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -7202,8 +7202,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/layout-spec-maintainer.lock.yml b/.github/workflows/layout-spec-maintainer.lock.yml index 26f9cafb2a..df1fb792c8 100644 --- a/.github/workflows/layout-spec-maintainer.lock.yml +++ b/.github/workflows/layout-spec-maintainer.lock.yml @@ -6948,7 +6948,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -7222,8 +7222,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/mergefest.lock.yml b/.github/workflows/mergefest.lock.yml index d898936764..647912f682 100644 --- a/.github/workflows/mergefest.lock.yml +++ b/.github/workflows/mergefest.lock.yml @@ -7569,7 +7569,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'push_to_pull_request_branch')) env: @@ -7753,7 +7753,7 @@ jobs: const { data: pullRequest } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: pullNumber + pull_number: pullNumber, }); branchName = pullRequest.head.ref; prTitle = pullRequest.title || ""; @@ -7789,9 +7789,10 @@ jobs: const hasChanges = !isEmpty; core.info(`Switching to branch: ${branchName}`); try { - await exec.exec("git fetch origin"); + core.info(`Fetching branch: ${branchName}`); + await exec.exec(`git fetch origin ${branchName}:refs/remotes/origin/${branchName}`); } catch (fetchError) { - core.setFailed(`Failed to fetch from origin: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); + core.setFailed(`Failed to fetch branch ${branchName}: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); return; } try { diff --git a/.github/workflows/org-wide-rollout.lock.yml b/.github/workflows/org-wide-rollout.lock.yml index 7db55a975c..7623069457 100644 --- a/.github/workflows/org-wide-rollout.lock.yml +++ b/.github/workflows/org-wide-rollout.lock.yml @@ -9299,7 +9299,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -9572,8 +9572,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml index 1ed65768a4..0961c92095 100644 --- a/.github/workflows/poem-bot.lock.yml +++ b/.github/workflows/poem-bot.lock.yml @@ -11560,7 +11560,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -11837,8 +11837,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); @@ -12931,7 +12931,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'push_to_pull_request_branch')) env: @@ -13116,7 +13116,7 @@ jobs: const { data: pullRequest } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: pullNumber + pull_number: pullNumber, }); branchName = pullRequest.head.ref; prTitle = pullRequest.title || ""; @@ -13152,9 +13152,10 @@ jobs: const hasChanges = !isEmpty; core.info(`Switching to branch: ${branchName}`); try { - await exec.exec("git fetch origin"); + core.info(`Fetching branch: ${branchName}`); + await exec.exec(`git fetch origin ${branchName}:refs/remotes/origin/${branchName}`); } catch (fetchError) { - core.setFailed(`Failed to fetch from origin: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); + core.setFailed(`Failed to fetch branch ${branchName}: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); return; } try { diff --git a/.github/workflows/q.lock.yml b/.github/workflows/q.lock.yml index 75c8c9564b..7594203ff9 100644 --- a/.github/workflows/q.lock.yml +++ b/.github/workflows/q.lock.yml @@ -8798,7 +8798,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -9074,8 +9074,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/security-fix-pr.lock.yml b/.github/workflows/security-fix-pr.lock.yml index a73458ace5..e2ca635067 100644 --- a/.github/workflows/security-fix-pr.lock.yml +++ b/.github/workflows/security-fix-pr.lock.yml @@ -6724,7 +6724,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -6998,8 +6998,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/slide-deck-maintainer.lock.yml b/.github/workflows/slide-deck-maintainer.lock.yml index 1e0735eea4..38ad61cee3 100644 --- a/.github/workflows/slide-deck-maintainer.lock.yml +++ b/.github/workflows/slide-deck-maintainer.lock.yml @@ -7222,7 +7222,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -7495,8 +7495,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/spec-kit-execute.lock.yml b/.github/workflows/spec-kit-execute.lock.yml index 35bf0e874c..5a3c9771ba 100644 --- a/.github/workflows/spec-kit-execute.lock.yml +++ b/.github/workflows/spec-kit-execute.lock.yml @@ -7324,7 +7324,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -7598,8 +7598,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/spec-kit-executor.lock.yml b/.github/workflows/spec-kit-executor.lock.yml index 4cc2210414..a6105ed85a 100644 --- a/.github/workflows/spec-kit-executor.lock.yml +++ b/.github/workflows/spec-kit-executor.lock.yml @@ -7199,7 +7199,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -7473,8 +7473,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/technical-doc-writer.lock.yml b/.github/workflows/technical-doc-writer.lock.yml index e4d2a0c3bd..74b39ef652 100644 --- a/.github/workflows/technical-doc-writer.lock.yml +++ b/.github/workflows/technical-doc-writer.lock.yml @@ -7810,7 +7810,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -8084,8 +8084,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml index 11f4608ea5..9bd1c36b49 100644 --- a/.github/workflows/tidy.lock.yml +++ b/.github/workflows/tidy.lock.yml @@ -7483,7 +7483,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -7759,8 +7759,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); @@ -8005,7 +8005,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'push_to_pull_request_branch')) env: @@ -8189,7 +8189,7 @@ jobs: const { data: pullRequest } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: pullNumber + pull_number: pullNumber, }); branchName = pullRequest.head.ref; prTitle = pullRequest.title || ""; @@ -8225,9 +8225,10 @@ jobs: const hasChanges = !isEmpty; core.info(`Switching to branch: ${branchName}`); try { - await exec.exec("git fetch origin"); + core.info(`Fetching branch: ${branchName}`); + await exec.exec(`git fetch origin ${branchName}:refs/remotes/origin/${branchName}`); } catch (fetchError) { - core.setFailed(`Failed to fetch from origin: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); + core.setFailed(`Failed to fetch branch ${branchName}: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); return; } try { diff --git a/.github/workflows/unbloat-docs.lock.yml b/.github/workflows/unbloat-docs.lock.yml index 7dfea21a32..a3df92ece2 100644 --- a/.github/workflows/unbloat-docs.lock.yml +++ b/.github/workflows/unbloat-docs.lock.yml @@ -8015,7 +8015,7 @@ jobs: with: token: ${{ github.token }} persist-credentials: false - fetch-depth: 0 + fetch-depth: 1 - name: Configure Git credentials if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request')) env: @@ -8291,8 +8291,8 @@ jobs: } core.info(`Generated branch name: ${branchName}`); core.info(`Base branch: ${baseBranch}`); - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); core.info(`Branch should not exist locally, creating new branch from base: ${branchName}`); await exec.exec(`git checkout -b ${branchName}`); diff --git a/pkg/workflow/compiler_safe_outputs_consolidated.go b/pkg/workflow/compiler_safe_outputs_consolidated.go index 47c631887b..f407464cf6 100644 --- a/pkg/workflow/compiler_safe_outputs_consolidated.go +++ b/pkg/workflow/compiler_safe_outputs_consolidated.go @@ -1289,7 +1289,7 @@ func (c *Compiler) buildCreatePullRequestPreStepsConsolidated(data *WorkflowData preSteps = append(preSteps, " with:\n") preSteps = append(preSteps, fmt.Sprintf(" token: %s\n", checkoutToken)) preSteps = append(preSteps, " persist-credentials: false\n") - preSteps = append(preSteps, " fetch-depth: 0\n") + preSteps = append(preSteps, " fetch-depth: 1\n") if c.trialMode { if c.trialLogicalRepoSlug != "" { preSteps = append(preSteps, fmt.Sprintf(" repository: %s\n", c.trialLogicalRepoSlug)) @@ -1340,7 +1340,7 @@ func (c *Compiler) buildPushToPullRequestBranchPreStepsConsolidated(data *Workfl preSteps = append(preSteps, " with:\n") preSteps = append(preSteps, fmt.Sprintf(" token: %s\n", checkoutToken)) preSteps = append(preSteps, " persist-credentials: false\n") - preSteps = append(preSteps, " fetch-depth: 0\n") + preSteps = append(preSteps, " fetch-depth: 1\n") if c.trialMode { if c.trialLogicalRepoSlug != "" { preSteps = append(preSteps, fmt.Sprintf(" repository: %s\n", c.trialLogicalRepoSlug)) diff --git a/pkg/workflow/js/create_pull_request.cjs b/pkg/workflow/js/create_pull_request.cjs index c4c1f58b21..6fd7faae76 100644 --- a/pkg/workflow/js/create_pull_request.cjs +++ b/pkg/workflow/js/create_pull_request.cjs @@ -346,9 +346,9 @@ async function main() { // Create a new branch using git CLI, ensuring it's based on the correct base branch - // First, fetch latest changes and checkout the base branch - core.info(`Fetching latest changes and checking out base branch: ${baseBranch}`); - await exec.exec("git fetch origin"); + // First, fetch the base branch specifically (since we use shallow checkout) + core.info(`Fetching base branch: ${baseBranch}`); + await exec.exec(`git fetch origin ${baseBranch}:${baseBranch}`); await exec.exec(`git checkout ${baseBranch}`); // Handle branch creation/checkout diff --git a/pkg/workflow/js/push_to_pull_request_branch.cjs b/pkg/workflow/js/push_to_pull_request_branch.cjs index a333318f11..4eb85a669f 100644 --- a/pkg/workflow/js/push_to_pull_request_branch.cjs +++ b/pkg/workflow/js/push_to_pull_request_branch.cjs @@ -211,7 +211,7 @@ async function main() { const { data: pullRequest } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: pullNumber + pull_number: pullNumber, }); branchName = pullRequest.head.ref; prTitle = pullRequest.title || ""; @@ -258,11 +258,12 @@ async function main() { // Switch to or create the target branch core.info(`Switching to branch: ${branchName}`); - // Fetch latest changes from origin + // Fetch the specific target branch from origin (since we use shallow checkout) try { - await exec.exec("git fetch origin"); + core.info(`Fetching branch: ${branchName}`); + await exec.exec(`git fetch origin ${branchName}:refs/remotes/origin/${branchName}`); } catch (fetchError) { - core.setFailed(`Failed to fetch from origin: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); + core.setFailed(`Failed to fetch branch ${branchName}: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`); return; } diff --git a/pkg/workflow/js/push_to_pull_request_branch.test.cjs b/pkg/workflow/js/push_to_pull_request_branch.test.cjs index 8ce269d370..c4b628f2cd 100644 --- a/pkg/workflow/js/push_to_pull_request_branch.test.cjs +++ b/pkg/workflow/js/push_to_pull_request_branch.test.cjs @@ -29,8 +29,8 @@ const mockCore = { summary: { addRaw: vi.fn().mockReturnThis(), write: vi.fn().mockResolvedValue() }, }, mockContext = { eventName: "pull_request", payload: { pull_request: { number: 123 }, repository: { html_url: "https://github.com/testowner/testrepo" } }, repo: { owner: "testowner", repo: "testrepo" } }, - mockGithub = { - graphql: vi.fn(), + mockGithub = { + graphql: vi.fn(), request: vi.fn(), rest: { pulls: { @@ -38,11 +38,11 @@ const mockCore = { data: { head: { ref: "feature-branch" }, title: "Test PR Title", - labels: [{ name: "bug" }, { name: "enhancement" }] - } - }) - } - } + labels: [{ name: "bug" }, { name: "enhancement" }], + }, + }), + }, + }, }; ((global.core = mockCore), (global.context = mockContext), @@ -256,8 +256,8 @@ const mockCore = { data: { head: { ref: "feature-branch" }, title: "[bot] Add new feature", - labels: [] - } + labels: [], + }, }), await executeScript(), expect(mockCore.info).toHaveBeenCalledWith('✓ Title prefix validation passed: "[bot] "'), @@ -272,8 +272,8 @@ const mockCore = { data: { head: { ref: "feature-branch" }, title: "Add new feature", - labels: [] - } + labels: [], + }, }), await executeScript(), expect(mockCore.setFailed).toHaveBeenCalledWith('Pull request title "Add new feature" does not start with required prefix "[bot] "')); @@ -287,8 +287,8 @@ const mockCore = { data: { head: { ref: "feature-branch" }, title: "Add new feature", - labels: [{ name: "automation" }, { name: "enhancement" }, { name: "feature" }] - } + labels: [{ name: "automation" }, { name: "enhancement" }, { name: "feature" }], + }, }), await executeScript(), expect(mockCore.info).toHaveBeenCalledWith("✓ Labels validation passed: automation,enhancement"), @@ -303,8 +303,8 @@ const mockCore = { data: { head: { ref: "feature-branch" }, title: "Add new feature", - labels: [{ name: "feature" }] - } + labels: [{ name: "feature" }], + }, }), await executeScript(), expect(mockCore.setFailed).toHaveBeenCalledWith("Pull request is missing required labels: automation, enhancement. Current labels: feature")); @@ -319,8 +319,8 @@ const mockCore = { data: { head: { ref: "feature-branch" }, title: "[automated] Add new feature", - labels: [{ name: "bot" }, { name: "feature" }, { name: "enhancement" }] - } + labels: [{ name: "bot" }, { name: "feature" }, { name: "enhancement" }], + }, }), await executeScript(), expect(mockCore.info).toHaveBeenCalledWith('✓ Title prefix validation passed: "[automated] "'), @@ -404,8 +404,8 @@ const mockCore = { data: { head: { ref: "feature-branch" }, title: "Test PR Title", - labels: [{ name: "bug" }, { name: "enhancement" }] - } + labels: [{ name: "bug" }, { name: "enhancement" }], + }, }), mockExec.getExecOutput.mockImplementation(async (command, args) => { return "git" === command && args && "status" === args[0] @@ -452,8 +452,8 @@ const mockCore = { data: { head: { ref: "feature-branch" }, title: "Test PR Title", - labels: [] - } + labels: [], + }, }), mockExec.getExecOutput.mockImplementation(async (command, args) => { if ("git" === command) throw new Error("Git command failed");