Skip to content

Commit e3c800d

Browse files
fix(source-control): Forgejo clone URLs under a src/branch mount stay unchanged
Forgejo may be mounted below any path, including one containing src/branch/, so a path ending in .git is always its clone URL. Also tells users that a pasted branch or file page clones the default branch. AI-assisted; verified with the tests and tools listed above. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 82e4732 commit e3c800d

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎docs/user/source-control.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ publish it. If Git has no name or email on that machine, the project is created
155155
first commit.
156156

157157
Use **Add Project** in the command palette (`Cmd/Ctrl+K`) to clone a repository. Choose a hosting
158-
provider or paste a Git URL, then choose where to save it. The project opens right away while the
158+
provider or paste a Git URL, then choose where to save it. A branch or file page copied from the
159+
browser also works: T3 Code clones that repository's default branch. The project opens right away while the
159160
clone runs in the background: you can write your first prompt, and sending waits until the files
160161
are in place. A toast tracks progress and lets you cancel; if the clone fails, retry it from the
161162
toast or from the banner above the composer. When the host refuses the machine's SSH key, T3 Code

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ describe("add project shared logic", () => {
7272
"https://scm.example.test/acme/tools/src/branch/worker",
7373
"https://scm.example.test/team/repo/src/branch/main/-/README.md",
7474
"https://code.company.test/team/repo/src/branch/main/docs",
75+
"https://forgejo.example.test/a/b/src/branch/mount/team/repo.git",
7576
]) {
7677
expect(normalizePastedCloneUrl(gitlabProject)).toBe(gitlabProject);
7778
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ export const definition = defineSourceControl({
9090
commitUrl: (input) => buildCommitUrl(input, "commit"),
9191
parseCommitUrl: (url) => parseCommitPath(url, COMMIT_PATH),
9292
repositoryUrlFromPage: (url, known) => {
93+
// A mount path may itself contain `src/branch/`, so a `.git` path is always the clone URL.
94+
if (url.pathname.replace(/\/$/u, "").endsWith(".git")) return null;
9395
const repositoryUrl = repositoryUrlFromPagePath(url, REPOSITORY_PAGE_PATH);
9496
// Elsewhere the same path is a GitLab project nested under groups named `src` and `branch`.
9597
return repositoryUrl === null || known ? repositoryUrl : url.href;

0 commit comments

Comments
 (0)