Skip to content

merge-pr.sh: land from fork checkouts, and add --explain - #505

Merged
bompus merged 6 commits into
mainfrom
fix/merge-pr-fork-explain
Oct 31, 2026
Merged

bompus merged 6 commits into
mainfrom
fix/merge-pr-fork-explain

Conversation

@bompus

@bompus bompus commented Oct 31, 2026

Copy link
Copy Markdown
Owner

merge-pr.sh asked gh which repository the current directory belongs to. A checkout of a fork also has the upstream remote, so gh answered with the upstream in every such checkout and the script refused them all.

The repository now comes from the pull request's name, and every gh call carries it. The script fetches and pushes through the remote whose URLs are that repository's (https or ssh, any case; origin first, or --remote), and refuses only when none is. A remote qualifies only when every URL it fetches from or pushes to matches, because git pushes to all of a remote's URLs. The HR_PUSH_LANDED list is compared case-insensitively now that the name is the one typed.

--explain runs the landing conditions read-only and prints met or UNMET for each: the PR is open, no open PR targets its head, review threads and review-body findings, the bot review of the head, bot review rounds against HR_REVIEW_ROUND_CAP (default 6, advisory), other checks on the head, the fetched head, the repository's own check, and for push-landed repositories the base ancestry and the head-branch lease. It exits 0 only when all are met, and it lands, pushes and deletes nothing. It runs the repository's check as a landing does.

Checked: tests written first (six failed); they cover a fork checkout, URL forms, --remote over an unmatched URL, a remote with a second URL for another repository, the case-folded push landing, and --explain met, unmet, broken-lease and merge cases, each leaving the remote untouched. bun run check and the skills tests pass.

…d, and add --explain

The script asked gh which repository the current directory belongs to. A fork checkout also has the upstream remote, so gh named the upstream and every fork checkout was refused. The repository now comes from the pull request's name, every gh call carries it, and the script fetches and pushes through the checkout's remote whose URL matches it (https or ssh, any case; origin first, or --remote), refusing only when none does. The HR_PUSH_LANDED list is compared case-insensitively now that the name is the one given.

--explain runs the landing conditions read-only and prints met or UNMET for each: the pull request is open, no open PR targets its head, review threads, the bot review of the head, bot review rounds against HR_REVIEW_ROUND_CAP, other checks, the fetched head, the repository's check, and for push-landed repositories the base ancestry and the head-branch lease. It exits 0 when all are met and 1 otherwise, and lands nothing.
…es to is the named repository's

Git fetches a remote's first URL and pushes to all of them, so a remote with an unrelated second URL would have landed the change in that repository too. A remote now qualifies only when all its url and pushurl values match. --explain printed the bot review rounds twice; it prints them once, and the tests count the lines and prove that --remote overrides an unmatched URL.
@bompus bompus added the author:anthropic Pull request written by a anthropic model label Oct 31, 2026
@bompus

bompus commented Oct 31, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@bompus-ai-review bompus-ai-review 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.

Bompus AI Review (GPT-6.1 Sol, xhigh reasoning): 2 finding(s).

…in URLs

A remote's configured URL is not what git fetches from or pushes to once url.<base>.insteadOf or pushInsteadOf applies, so a push URL rewritten to another repository passed the match, and an alias rewritten to the right one was refused. A remote now qualifies by git remote get-url --all and --push --all. URLs are parsed as URI or scp-style forms, so an explicit ssh or https port no longer breaks the match.

@bompus-ai-review bompus-ai-review 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.

Bompus AI Review (GPT-6.1 Sol, xhigh reasoning): 1 finding(s).

@bompus-ai-review bompus-ai-review 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.

Bompus AI Review (GPT-6.1 Sol, xhigh reasoning): 0 finding(s).

Review 3: only high findings and above are posted from here on.

@bompus
bompus merged commit 01b86f5 into main Oct 31, 2026
2 checks passed
@bompus
bompus deleted the fix/merge-pr-fork-explain branch October 31, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:anthropic Pull request written by a anthropic model

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant