Skip to content

Commit adcef67

Browse files
only21milclaude
andcommitted
fix(server): name the refused pull request's repository in its URL's case
The refusal and its rename hint printed the lower-cased comparison key, so a pull request of octocat/Hello-World read as octocat/hello-world. They now take the repository's spelling from the pull request URL's own path, the span the change request link reads as the repository, and fall back to the key's path for a URL that link cannot read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2a3e508 commit adcef67

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎apps/server/src/git/GitManager.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5284,7 +5284,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
52845284
pullRequest: {
52855285
number: 64,
52865286
title: "Another repository's PR",
5287-
url: "https://github.com/pingdotgg/codething-mvp/pull/64",
5287+
url: "https://github.com/pingdotgg/Codething-MVP/pull/64",
52885288
baseRefName: "main",
52895289
headRefName: "feature/elsewhere",
52905290
state: "open",
@@ -5310,7 +5310,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
53105310

53115311
const result = yield* preparePullRequestThread(manager, {
53125312
cwd: repoDir,
5313-
reference: "https://github.com/pingdotgg/codething-mvp/pull/64",
5313+
reference: "https://github.com/pingdotgg/Codething-MVP/pull/64",
53145314
mode,
53155315
threadId: asThreadId("thread-pr-elsewhere"),
53165316
}).pipe(Effect.result);
@@ -5327,7 +5327,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
53275327
_tag: "Failure",
53285328
failure: {
53295329
_tag: "GitManagerError",
5330-
detail: expect.stringContaining("not a checkout of pingdotgg/codething-mvp"),
5330+
detail: expect.stringContaining("not a checkout of pingdotgg/Codething-MVP"),
53315331
},
53325332
});
53335333
expect(prepared.ghCalls.some((call) => call.startsWith("pr checkout"))).toBe(false);
@@ -5397,7 +5397,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
53975397
expect(prepared.result).toMatchObject({
53985398
failure: {
53995399
detail:
5400-
"This project is not a checkout of pingdotgg/codething-mvp. Its remote acme names pingdotgg/codething-mvp; run `git remote rename acme upstream` to open the pull request here.",
5400+
"This project is not a checkout of pingdotgg/Codething-MVP. Its remote acme names pingdotgg/Codething-MVP; run `git remote rename acme upstream` to open the pull request here.",
54015401
},
54025402
});
54035403
}),

‎apps/server/src/git/GitManager.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,15 @@ function pullRequestBaseRepositoryKey(url: string): string | null {
342342
return key === null ? null : canonicalRepositoryKey(key);
343343
}
344344

345+
/** The pull request's repository in the case its URL writes it, else the path of its `key`. */
346+
function pullRequestRepositoryName(url: string, key: string): string {
347+
// The link's repository is lower-cased, but it spells the start of the URL's own path.
348+
const link = parseChangeRequestUrl(url);
349+
return link === null
350+
? splitRepositoryKey(key).path
351+
: new URL(url).pathname.slice(1, link.repository.length + 1);
352+
}
353+
345354
/** A repository key's host and the path below it. */
346355
function splitRepositoryKey(key: string): { readonly host: string; readonly path: string } {
347356
const slash = key.indexOf("/");
@@ -2715,7 +2724,7 @@ export const make = Effect.gen(function* () {
27152724
pullRequestWithRemoteInfo,
27162725
);
27172726
if (mismatch !== null) {
2718-
const repository = splitRepositoryKey(mismatch).path;
2727+
const repository = pullRequestRepositoryName(pullRequest.url, mismatch);
27192728
const baseRemote = forkBaseRemote(remotes, identity, pullRequest.url, mismatch);
27202729
// A fork clone needs the rename, not a project elsewhere, so each message gives one remedy.
27212730
const remedy =

0 commit comments

Comments
 (0)