@devries-cameron20 / t3code Mirror · read-only / commits / a9386ac8a6
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 12:15 UTC

fix(gitlab): a pasted repository URL is looked up by its project path on its host (#35209)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Dhairya committed Nov 15, 2026 at 10:17 UTC a9386ac8a6768f07db8839d8ebe34d923a92b833
2 files changed +58 -1
packages/source-control-gitlab/src/server/GitLabCli.test.ts
+32
@@ -268,6 +268,38 @@ layer("GitLabCli.layer", (it) => {
268 }),
269 );
270
271 + it.effect.each([
272 + { repository: "group/project", args: ["api", "projects/group%2Fproject"] },
273 + {
274 + repository: "https://gitlab.example.com:8443/group/sub/project.git",
275 + args: ["api", "--hostname", "gitlab.example.com:8443", "projects/group%2Fsub%2Fproject"],
276 + },
277 + {
278 + repository: "https://gitlab.com/group/project/-/tree/main",
279 + args: ["api", "--hostname", "gitlab.com", "projects/group%2Fproject"],
280 + },
281 + ])("looks up $repository by its project path", ({ repository, args }) =>
282 + Effect.gen(function* () {
283 + mockedRun.mockReturnValueOnce(
284 + Effect.succeed(
285 + processOutput(
286 + JSON.stringify({
287 + path_with_namespace: "group/project",
288 + web_url: "https://sourcecontrol.example.com/group/project",
289 + http_url_to_repo: "https://sourcecontrol.example.com/group/project.git",
290 + ssh_url_to_repo: "git@sourcecontrol.example.com:group/project.git",
291 + }),
292 + ),
293 + ),
294 + );
295 +
296 + const glab = yield* GitLabCli.GitLabCli;
297 + yield* glab.getRepositoryCloneUrls({ cwd: "/repo", repository });
298 +
299 + expect(mockedRun).toHaveBeenCalledWith(expect.objectContaining({ command: "glab", args }));
300 + }),
301 + );
302 +
303 it.effect("keeps non-merge-request not-found failures generic", () =>
304 Effect.gen(function* () {
305 const cause = new VcsProcessExitError({
packages/source-control-gitlab/src/server/GitLabCli.ts
+26 -1
@@ -421,6 +421,26 @@ function parseRepositoryPath(repository: string): {
421 return { namespacePath, projectPath };
422 }
423
424 +function parseRepositoryLookup(repository: string): {
425 + readonly host: string | null;
426 + readonly projectPath: string;
427 +} {
428 + const trimmed = repository.trim();
429 + if (!/^https?:\/\//i.test(trimmed)) return { host: null, projectPath: repository };
430 + try {
431 + const url = new URL(trimmed);
432 + const projectPath = decodeURIComponent(url.pathname)
433 + .replace(/\/-(?:\/.*)?$/, "")
434 + .replace(/^\/+|\/+$/g, "")
435 + .replace(/\.git$/, "");
436 + return projectPath.length === 0
437 + ? { host: null, projectPath: repository }
438 + : { host: url.host, projectPath };
439 + } catch {
440 + return { host: null, projectPath: repository };
441 + }
442 +}
443 +
444 // glab prints a missing project or merge request as a bare 404, and an expired
445 // OAuth login as an `invalid_grant` refresh failure without suggesting `glab auth login`.
446 const classifyGlabFailure = (stderr: string): VcsProcessExitFailureKind | null => {
@@ -568,9 +588,14 @@ export const make = Effect.gen(function* () {
588 );
589 }),
590 getRepositoryCloneUrls: Effect.fn("GitLabCli.getRepositoryCloneUrls")(function (input) {
591 + const { host, projectPath } = parseRepositoryLookup(input.repository);
592 return execute({
593 cwd: input.cwd,
573 - args: ["api", `projects/${encodeURIComponent(input.repository)}`],
594 + args: [
595 + "api",
596 + ...(host === null ? [] : ["--hostname", host]),
597 + `projects/${encodeURIComponent(projectPath)}`,
598 + ],
599 }).pipe(
600 Effect.map((result) => result.stdout.trim()),
601 Effect.flatMap((raw) =>