Skip to content

Commit 82e4732

Browse files
fix(source-control): page URLs on known hosts map even when the ref ends in .git
On a recognized host its own page route already tells a page from a clone URL, so the .git clone-URL guard only applies to unrecognized hosts. AI-assisted; verified with the tests and tools listed above. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 930287e commit 82e4732

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎packages/client-runtime/src/operations/projects.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ describe("add project shared logic", () => {
8585
["https://git.cafe/pingdotgg/t3code/tree/main", "/tree/", "t3code"],
8686
["https://gitlab.example.test/g/p/-/blob/main/src/branch/x", "/-/", "p"],
8787
["https://code.company.test/g/p/-/tree/main", "/-/", "p"],
88+
["https://github.com/pingdotgg/t3code/tree/release.git", "/tree/", "t3code"],
89+
["https://gitlab.com/g/p/-/blob/main/template.git", "/-/", "p"],
8890
] as const) {
8991
const cloneUrl = normalizePastedCloneUrl(pageUrl);
9092
expect(cloneUrl).not.toContain(pageRoute);

‎packages/source-control-core/src/shared/definition.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,13 @@ export function makeSourceControlDefinitionRegistry(
768768
},
769769
repositoryUrlFromPage: (value) => {
770770
const url = httpUrl(value);
771-
// A path ending in `.git` is already a clone URL, whatever routes it happens to contain.
772-
if (url === null || url.pathname.replace(/\/$/u, "").endsWith(".git")) return null;
771+
if (url === null) return null;
773772
// A recognized host's paths are its own, so another host's any-host route never rewrites them.
774773
const remote = parseGitRemoteHost(value);
775774
const owner = remote === null ? undefined : remoteOwner(remote);
776775
if (owner) return owner.repositoryUrlFromPage?.(url, true) ?? null;
776+
// Elsewhere a path ending in `.git` is already a clone URL, whatever routes it contains.
777+
if (url.pathname.replace(/\/$/u, "").endsWith(".git")) return null;
777778
// On an unrecognized host, only rewrite when every route that matches agrees. A route that
778779
// answers with the page itself says it may already be the clone URL.
779780
const [repositoryUrl, ...others] = new Set(

0 commit comments

Comments
 (0)