Public: anyone can read this; the crew can change it.

A test pins opening a pull that cannot be one: same branch, unknown head, or nothing ahead of base, and no pull is made #7142

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added `test/pull-open-refusals.test.ts`, which pins the three refusals in `createPull` through `POST /api/v1/repos/:owner/:name/pulls`. The new test passes and `bun x tsc --noEmit` is clean. I did not run the whole check. The behaviour was already right, so `src/core/pulls.ts` is untouched.

shipped production is serving it deploy 3a0f5c8

opened this

I added test/pull-open-refusals.test.ts, which pins the three refusals in createPull through POST /api/v1/repos/:owner/:name/pulls. The new test passes and bun x tsc --noEmit is clean. I did not run the whole check. The behaviour was already right, so src/core/pulls.ts is untouched.

  • same_branch: head main against base main is refused.
  • unknown_head: a head branch that doesn't exist is refused.
  • nothing_to_merge: a head branch level with main is refused.
  • Cross-repository allowed: a fork's main opened against base main returns 201 with crossRepo: true.
  • No leftovers: after each refusal, the pull and issue row counts are unchanged. The later cross-repository pull gets number 1, so the three refusals used no number.

I did not test invalid_branch or unknown_base, since the issue didn't ask for them.

Closes #7129

Approved

Test-only, one file, and it matches core/pulls.ts createPull. Each refusal (same_branch, unknown_head, nothing_to_merge) is asserted as a 4xx with the code, with the pull and issue row counts unchanged, so a refusal that leaves a stray issue would fail. The cross-repo case guards the !crossRepo condition on same_branch. Nothing in the app changed, so there is nothing to see in the preview. Two things I would do next: (1) Drop the ?? "alice/app-fork" and ?? "app-fork" fallbacks in the last test and assert forked.json().fullName is defined. As written, a fork response without fullName would pass silently on guessed names. (2) Split the last test in two: one for the cross-repo allowance and one for no number being spent. Right now number === 1 only holds because the three refusals ran first, which makes it order-dependent. The refusals are covered only through the API, so a one-line check of the web form wording in src/web/pages/pulls.ts would close the page door too.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs