Skip to content

fix(land-and-deploy): check fork branches in head repo - #2725

Closed
pttydou wants to merge 1 commit into
garrytan:mainfrom
pttydou:fix/2696-fork-branch-reconciliation
Closed

pttydou wants to merge 1 commit into
garrytan:mainfrom
pttydou:fix/2696-fork-branch-reconciliation

Conversation

@pttydou

@pttydou pttydou commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Why (in your own words)

When a merge succeeds remotely but local cleanup fails, land-and-deploy reconciles the PR branch before offering deletion. That check always queried the checkout's origin, so a branch from a fork produced an empty result and was incorrectly reported as already cleaned up. This change resolves the PR's actual head repository and uses it consistently for the check and the confirm-first deletion path, while preserving same-repository behavior and failing closed when metadata is unavailable.

Live evidence

$ gh pr view 2723 --repo garrytan/gstack --json headRepository,headRefName --jq '[.headRepository.nameWithOwner, .headRefName] | @tsv'
yansigit/gstack codex/minimal-codex-plugin

$ git ls-remote --heads https://github.com/garrytan/gstack.git codex/minimal-codex-plugin
# no output (the old origin-based check would classify this as cleaned up)

$ git ls-remote --heads https://github.com/yansigit/gstack.git codex/minimal-codex-plugin
bf78df00... refs/heads/codex/minimal-codex-plugin

$ gh pr view 2722 --repo garrytan/gstack --json headRepository,headRefName --jq '[.headRepository.nameWithOwner, .headRefName] | @tsv'
garrytan/gstack ponytail-inspiration-review

$ git ls-remote --heads https://github.com/garrytan/gstack.git ponytail-inspiration-review
74549cee... refs/heads/ponytail-inspiration-review

$ bun test test/land-and-deploy-postfail.test.ts
14 pass
0 fail
36 expect() calls

Scope

  • Changed: The §4a-postfail branch reconciliation now reads headRepository.nameWithOwner with headRefName, queries that repository directly, and uses the same target for any confirmed deletion. Added regression coverage and regenerated the section output.
  • Verified live by: Comparing a current fork PR (v1.74.0.0 feat(codex): add minimal repo-local plugin bridge #2723) against both the base repository and its actual head repository; checking a same-repository PR (v1.75.0.0 feat: ponytail import wave — simplification review lens, arm benchmark, reuse ladder, instruction-tier digest #2722); running the focused 14-test suite, generated-doc freshness check, git diff --check, and the full build.
  • Did NOT test: An actual post-merge branch deletion, because that would be destructive. Paid Anthropic E2E/LLM evals were not run. The Windows-curated free suite also contains unrelated host-environment failures where symlink creation is denied, jq is unavailable, or MSYS path handling differs.

Liveness proof (required)

image

Checklist

@trunk-io

trunk-io Bot commented Aug 29, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for this, @pttydou. The fix is now on main: land-and-deploy resolves the PR's head repository owner and name and checks the branch there (merge-and-deploy.md.tmpl) (fixed in v1.78.0.0, #2752). Closing as superseded; if you still see the problem on the latest gstack, please open an issue with ./setup --status output.

@capy-ai capy-ai Bot closed this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant