Skip to content

fix(source-control): run ready's branch update with --dir and git -C - #15946

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/ready-branch-update-dir
Nov 13, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/ready-branch-update-dir

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Refs: #15900

Summary

Item 1, option (a), of #15900: the owner decided that the pull-request scripts name the repository with --dir <checkout>, not environment variables. This PR applies that to the last step that still ran from the shell's directory, ready's branch-update sequence (2.5.2). A caller with no --dir gets the same behavior as before.

Fix

  • scripts/branch-update-signals.sh takes --dir <checkout>, as fetch-all-pr-comments.sh and resolve-remote.sh do. Every git read (the base fetch, the overlap diff, the head checks) runs in that checkout, and the repository is resolved there with target-repo.sh, which honors GH_REPO. --repo still wins. A missing, empty, repeated or non-directory --dir is a usage error (exit 2). If target-repo.sh refuses, its reason goes to stderr and every signal reads unknown, as any other failed read does. Without --dir, the script uses the shell's directory and gh's {owner}/{repo} placeholders, as before.
  • Skill ready-for-review.md, "Decide and carry out the update", defines <branch-checkout>: the path of the checkout that has the branch checked out. For a pull request, that is the worktree pr-worktree.sh --pr "$PR_NUMBER" --dir "<checkout>" prints. Step 2 used to say "from the PR's checkout"; it now says "in <branch-checkout>". push-branch.sh, resolve-remote.sh and branch-update-signals.sh get --dir "<branch-checkout>", and the local merge fallback runs git -C "<branch-checkout>" fetch and merge. 2.5.2's skipped-step push and its completion check name it too.
  • GitHub ready-for-review.md: the fast-forward after the forge's update and the signed-head read (cat-file commit HEAD) run with git -C "<branch-checkout>".
  • The pull-request-ready-merges-base-never-rebases grader's merge regex also accepts git -C <dir> merge. Without that change, the docs' new command form would not count as a merge.

<branch-checkout> is used rather than <checkout> because 2.5.3 lets <checkout> be any checkout of the repository, such as the main checkout. Merging the base there, or pushing that checkout's HEAD with push-branch.sh --dir --pr, would land on the wrong branch.

Fork checkouts

The repository a fork checkout resolves to in ready does not change. 2.5.1 exports GH_REPO from target-repo.sh --dir "<checkout>", and both the old placeholder path and target-repo.sh follow GH_REPO. Without --dir, the script works as before.

Verification

  • branch-update-signals.test.sh: 410 passed, 0 failed. The new cases run from a shell outside every checkout. They cover: --dir reads the checkout's repository, head_sha and overlap; no --dir still uses the placeholders; --repo wins over --dir; GH_REPO wins with --dir; target-repo.sh refuses for two unrelated GitHub remotes; and four usage errors.
  • Ran by hand, all passing: reassess-state.test.sh (109), gh-forge.test.sh (83), ready-verify-local.test.sh (7) and ready-flip.test.sh (59). shellcheck -x is clean on both changed scripts.
  • The pre-push check-affected hook passed. Suites over the 120-second budget are left to CI.
  • Not run: a live ready from outside a checkout against a real PR.

Related

Remaining

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vcupomh2tPSB9BXCVa1AeL

branch-update-signals.sh takes --dir <checkout>: git reads run there and
the repository resolves with target-repo.sh (GH_REPO honored, --repo
wins). Without --dir nothing changes.

Ready 2.5.2 and the shared update sequence name <branch-checkout>, the
checkout holding the branch, for push-branch.sh, resolve-remote.sh and
the signals (--dir) and for the base fetch and merge, the fast-forward
and the signed-head read (git -C), so a shell outside the checkout can
run the step. The base-merge eval grader accepts git -C.

Refs: #15900

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vcupomh2tPSB9BXCVa1AeL
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR body contract — issue linkage

This PR body conforms to the issue-linkage contract. Nothing to do.

@github-actions github-actions Bot added needs-issue-linkage Pull request body has no issue linkage line; set by the PR-contract check, advisory. and removed needs-issue-linkage Pull request body has no issue linkage line; set by the PR-contract check, advisory. labels Nov 13, 2026
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 13, 2026 11:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T11:45:15.371547Z 4be2189 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4be218995b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed a0f18d6fa33d1aff09e6cc3f1b4c840a1bcf7b74: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15946 (incremental, 4be2189 → a0f18d6)

I found no security issues. This was an incremental review: I read every hunk of both files in scope (2 of 2) in .claude-lane/incremental.diff. Neither file matches a trusted-path glob. Neither is a trust control, merge hold, plugin manifest or deletion from a standing instruction.

What I checked

  • plugins/source-control/scripts/branch-update-signals.sh:77. cd -- "$CHECKOUT" becomes CDPATH='' cd -- "$CHECKOUT" >/dev/null 2>&1.

    • No CDPATH lookup: clearing CDPATH for the cd means a relative --dir can no longer resolve through an exported CDPATH to some other directory. That rules out reading git state or the repository from a checkout the caller did not name.
    • Clean stdout: sending stdout to /dev/null drops the directory that cd prints, so the script's stdout stays one JSON object.
    • No new input: the value is still quoted and guarded with --, so it adds no injection surface.
    • Still fails closed: a failed cd still ends in usage.

    The change narrows behavior and widens nothing.

  • plugins/source-control/scripts/branch-update-signals.test.sh. It adds one test that runs a relative --dir under an exported CDPATH. It has no security-relevant surface.

Blocking only: this lane already reviewed an earlier head, so this review was blocking only and would have dropped SUGGESTION findings. There were none.
Prior findings: the only earlier post is the summary comment for 4be2189, which had 0 findings. Nothing carries over.
Embedded text: the PR context has no instructions aimed at this lane.
Spend: nothing beyond this review run.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed a0f18d6fa33d1aff09e6cc3f1b4c840a1bcf7b74: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Code review (incremental, blocking only): PR #15946 at a0f18d6

This lane reviewed an earlier head (4be2189), so this pass reports blocking findings only. It covers just the two files the push changed: branch-update-signals.sh and branch-update-signals.test.sh.

No findings.

What I checked

  • branch-update-signals.sh:77. The line now reads CDPATH='' cd -- "$CHECKOUT" >/dev/null 2>&1 || usage.
    • cd is a regular builtin, so the CDPATH='' prefix applies to that one command and does not persist in the script.
    • With CDPATH empty, a relative --dir resolves only against the current directory.
    • The new >/dev/null also stops bash from echoing the resolved path to stdout, which would have landed ahead of the JSON.
    • A path that cd can't enter still falls through to usage, which exits 2.
    • This is the same way pr-worktree.sh clears CDPATH.
  • New test case (branch-update-signals.test.sh:509-515).
    • CDPATH="$WORKDIR" is a prefix assignment on the run shell function. Bash exports it for the duration of that call, so the bash "$SIGNALS" child inherits it.
    • run itself runs cd "$WORKDIR" with an absolute path, so the fixture setup does not depend on CDPATH.
    • On the old line, cd -- app would have resolved through CDPATH to $WORKDIR/app and printed that path. OUT would then hold two lines, and the "1 object" assertion would fail, so the test can catch the regression.
    • An empty OUT gives "1 " and also fails, so the assertion has no blind spot there.
  • Settled thread. The owner's answer to the earlier CDPATH thread on this line (fixed in a0f18d6) matches what the head now does; I did not re-raise it. The owner's report of 414 of 414 tests passing is their own claim: I had no shell and ran nothing.

Closing issue. The PR uses Refs: #15900, not a closing keyword, so there were no acceptance criteria to check.

Spend. None.

Verifier dropped 0 of 0 candidates.

A relative --dir under an exported CDPATH resolved through it and cd
printed the directory to stdout ahead of the JSON, breaking the pipe
into branch-update-method.sh. Clear CDPATH and silence the cd, as
pr-worktree.sh clears it, and test stdout is one JSON object.

Refs: #15900

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vcupomh2tPSB9BXCVa1AeL
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 2d2bee9 Nov 13, 2026
52 checks passed
@kyle-sexton
kyle-sexton deleted the fix/ready-branch-update-dir branch November 13, 2026 12:09
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant