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
Check · Review · Land · Live done — Landed and live in production.
`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
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
mainto 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
configand itsorigin_id,origin_full_name,origin_remote_idandorigin_html_urlcolumns 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.
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.
reattachMirroralready behaved as the issue describes, so I changed no application code. I addedtest/mirror-reattach-refusals.test.tswith four tests. They pass andbun x tsc --noEmitis clean. I did not run the rest of the suite.mainto 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.configand itsorigin_id,origin_full_name,origin_remote_idandorigin_html_urlcolumns are identical to before.I also added an optional
formerNamesfield to the fake origin intest/fake-origin.ts, so a renamed repo still answers to its old name, as a real forge redirects.reattachMirrorlooks 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), whichorigins-reconnect.test.tsalready covers.To try it:
bun test test/mirror-reattach-refusals.test.ts.Closes #7089