Public: anyone can read this; the crew can change it.
web ui setup: the first push to mel/proj was refused once on the check host, cause unknown #17052
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/16335-web-ui-setup-the-first-push-to-mel-proj → main 0 commits fork 2 threads · 2 unresolved
1 file
changed +24
−1
test/web-ui.test.ts +24 −1
| @@ -101,7 +101,30 @@ describe("web ui", () => { | ||
| 101 | 101 | await git(["add", "."], repo); |
| 102 | 102 | await git(["commit", "-q", "-m", "first"], repo); |
| 103 | 103 | const remote = `http://mel:web-ui-password@localhost:${servers.port}/mel/proj.git`; |
| 104 | await git(["push", "-q", remote, "main"], repo); | |
| 104 | // The first push is the one #16335 saw refused on the check host once. When it fails, say | |
| 105 | // what the forge thinks of the repository too, so the log names which cause it was: the | |
| 106 | // repository missing (`/new`), the credentials (401/403), or the hook. | |
| 107 | try { | |
| 108 | await git(["push", "-q", remote, "main"], repo); | |
| 109 | } catch (e) { | |
| 110 | // A probe that throws must not replace git's own message. | |
| 111 | const probe = async (what: string, url: string, headers: Record<string, string>) => { | |
| 112 | try { | |
| 113 | return `${what} answered ${(await fetch(url, { headers })).status}`; | |
| 114 | } catch (err) { | |
| 115 | return `${what} probe failed: ${(err as Error).message}`; | |
| 116 | } | |
| 117 | }; | |
| 118 | const seen = await probe("GET /mel/proj", `${base}/mel/proj`, { cookie: owner }); | |
| 119 | const info = await probe( | |
| 120 | "receive-pack advertisement with mel's credentials", | |
| 121 | `${base}/mel/proj.git/info/refs?service=git-receive-pack`, | |
| 122 | { authorization: `Basic ${btoa("mel:web-ui-password")}` }, | |
| 123 | ); | |
| 124 | // 200: repository, credentials and hook path are fine, the refusal came later; | |
| 125 | // 401/403: the credentials; 404: the repository is missing. | |
| 126 | throw new Error(`${(e as Error).message}\n(#16335: ${seen}; ${info})`, { cause: e }); | |
| 127 | } | |
| 105 | 128 | await git(["checkout", "-q", "-b", "topic"], repo); |
| 106 | 129 | await writeFile(join(repo, "a.txt"), "two\n"); |
| 107 | 130 | await git(["commit", "-qam", "second"], repo); |
new above
offline
Probe fetches can throw and would mask
e. Wrap them, and always rethrow with the git stderr included.