| ... | ... | @@ -513,6 +513,47 @@ describe("GitHubSourceControlProvider writes", () => { |
| 513 | 513 | assert.deepStrictEqual(requests, ["GET user", "POST orgs/acme/repos"]); |
| 514 | 514 | }).pipe(Effect.provide(layer)); |
| 515 | 515 | }); |
| 516 | |
| 517 | it.effect("looks up a bare repository name under the signed-in account on that host", () => { |
| 518 | const requests: Array<string> = []; |
| 519 | return Effect.gen(function* () { |
| 520 | const gh = yield* makeProvider({ |
| 521 | rest: (input) => |
| 522 | Effect.sync(() => { |
| 523 | requests.push(`${input.host} ${input.method ?? "GET"} ${input.path}`); |
| 524 | return input.path === "user" |
| 525 | ? restResponse({ login: "me" }) |
| 526 | : restResponse({ |
| 527 | full_name: "me/notes", |
| 528 | html_url: `https://${input.host}/me/notes`, |
| 529 | ssh_url: `git@${input.host}:me/notes.git`, |
| 530 | }); |
| 531 | }), |
| 532 | }); |
| 533 | |
| 534 | const urls = yield* gh.getRepositoryCloneUrls({ |
| 535 | cwd: "/repo", |
| 536 | context: githubContext("code.example.test"), |
| 537 | repository: " notes.git ", |
| 538 | }); |
| 539 | |
| 540 | assert.deepStrictEqual(urls, { |
| 541 | nameWithOwner: "me/notes", |
| 542 | url: "https://code.example.test/me/notes", |
| 543 | sshUrl: "git@code.example.test:me/notes.git", |
| 544 | }); |
| 545 | assert.deepStrictEqual(requests, [ |
| 546 | "code.example.test GET user", |
| 547 | "code.example.test GET repos/me/notes", |
| 548 | ]); |
| 549 | // Malformed names are still refused before any request. |
| 550 | for (const repository of ["me/", "/notes", "a/b/c/d", "", "two words"]) { |
| 551 | const error = yield* Effect.flip(gh.getRepositoryCloneUrls({ cwd: "/repo", repository })); |
| 552 | assert.include(error.message, "Repositories are named owner/name."); |
| 553 | } |
| 554 | assert.strictEqual(requests.length, 2); |
| 555 | }); |
| 556 | }); |
| 516 | 557 | }); |
| 517 | 558 | |
| 518 | 559 | describe("GitHubSourceControlProvider.checkoutChangeRequest", () => { |