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

A test pins reattaching a mirror: it refuses a different repository, or one already mirrored #7154

Merged opened this

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

Merged

`reattachMirror` already behaved as the issue describes, so I changed no application code. I added `test/mirror-reattach-refusals.test.ts` with four tests. They pass and `bun x tsc --noEmit` is clean. I did not run the rest of the suite.

shipped production is serving it deploy 1f3280d

opened this

reattachMirror already behaved as the issue describes, so I changed no application code. I added test/mirror-reattach-refusals.test.ts with four tests. They pass and bun x tsc --noEmit is clean. I did not run the rest of the suite.

  • Rename: a mirror whose origin repo was renamed (same remote id) reattaches under the new name. After one more upstream commit, a sync brings the mirror's main to the upstream tip.
  • not_the_same_repo: the repo is re-created upstream under the same name with a new id, and the reattach is refused.
  • already_mirrored: another local mirror already holds the same remote through a different origin, and the reattach is refused.
  • After each refusal: the mirror's git config and its origin_id, origin_full_name, origin_remote_id and origin_html_url columns are identical to before.

I also added an optional formerNames field to the fake origin in test/fake-origin.ts, so a renamed repo still answers to its old name, as a real forge redirects. reattachMirror looks the repo up by the name the mirror remembers, so the rename test needs this.

I made the origin rows directly instead of through the connect endpoint. Connecting would reattach the frozen mirror on its own before the test could call the action.

Not covered: the other refusals (wrong_host, remote_unknown, origin_cannot_see), which origins-reconnect.test.ts already covers.

To try it: bun test test/mirror-reattach-refusals.test.ts.

Closes #7089

commented

reattachMirror already behaved as the issue describes, so I changed no application code. I added test/mirror-reattach-refusals.test.ts with four tests. They pass and bun x tsc --noEmit is clean. I did not run the rest of the suite.

  • Rename: a mirror whose origin repo was renamed (same remote id) reattaches under the new name. After one more upstream commit, a sync brings the mirror's main to the upstream tip.
  • not_the_same_repo: the repo is re-created upstream under the same name with a new id, and the reattach is refused.
  • already_mirrored: another local mirror already holds the same remote through a different origin, and the reattach is refused.
  • After each refusal: the mirror's git config and its origin_id, origin_full_name, origin_remote_id and origin_html_url columns are identical to before.

I also added an optional formerNames field to the fake origin in test/fake-origin.ts, so a renamed repo still answers to its old name, as a real forge redirects. reattachMirror looks the repo up by the name the mirror remembers, so the rename test needs this.

I made the origin rows directly instead of through the connect endpoint. Connecting would reattach the frozen mirror on its own before the test could call the action.

Not covered: the other refusals (wrong_host, remote_unknown, origin_cannot_see), which origins-reconnect.test.ts already covers.

To try it: bun test test/mirror-reattach-refusals.test.ts.

Approved

Test-only change; no served page, so the preview has nothing new to show (I did not run the new file: my clone is at base). Read in full: the four tests cover the rename success path, not_the_same_repo and already_mirrored, and each refusal asserts that the git config and origin columns are unchanged. The fake-origin formerNames addition is small and optional. Next I would do two things. 1) The tests share state in order (the id is flipped to 99 and back, and the rename persists), so wrap the restores in try/finally or reset in afterEach, so one failure cannot cascade into the later tests. 2) This spins up a second forge and does real git clones with a 60s default timeout. Watch its runtime against the per-test time budget (#1242), and consider the fake clone URL if it ever turns slow or flaky. This is a test-only pull outside the pipeline-first list, but it is small and single-purpose.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs