From 691a9f8118330b119fd6124a9393bc31f473f4c5 Mon Sep 17 00:00:00 2001 From: Dzmitry Lopukh Date: Mon, 5 Oct 2026 11:48:02 +0200 Subject: [PATCH] fix(analytics): keep dots in repository name when resolving git remote detectGitRemoteRepo rejected dots in the repo segment, so remotes like git@github.com:owner/my.repo.git returned undefined and CLI Analytics fell back to the local folder path instead of owner/repo. Fixes EPMCDME-15510 Generated with AI Co-Authored-By: codemie-ai --- src/utils/__tests__/processes-git.test.ts | 12 ++++++++++++ src/utils/processes.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils/__tests__/processes-git.test.ts b/src/utils/__tests__/processes-git.test.ts index 83d1bbda2..2a710aa5a 100644 --- a/src/utils/__tests__/processes-git.test.ts +++ b/src/utils/__tests__/processes-git.test.ts @@ -46,6 +46,18 @@ describe('detectGitRemoteRepo', () => { expect(await detectGitRemoteRepo('/repo')).toBe('org/repo'); }); + it.each([ + ['SSH with .git', 'git@github.com:test-owner/my.repo.git', 'test-owner/my.repo'], + ['SSH without .git', 'git@github.com:test-owner/my.repo', 'test-owner/my.repo'], + ['HTTPS with .git', 'https://github.com/test-owner/my.repo.git', 'test-owner/my.repo'], + ['HTTPS without .git', 'https://github.com/vercel/next.js', 'vercel/next.js'], + ['GitHub Pages repo', 'git@github.com:user/user.github.io.git', 'user/user.github.io'], + ['multiple dots', 'https://github.com/org/a.b.c.git', 'org/a.b.c'], + ])('keeps dots in repository name (%s)', async (_label, url, expected) => { + mockExecAsync.mockResolvedValue({ stdout: `${url}\n`, stderr: '' }); + expect(await detectGitRemoteRepo('/repo')).toBe(expected); + }); + it('returns undefined when git command fails (no remote)', async () => { mockExecAsync.mockRejectedValue(new Error('fatal: No such remote origin')); expect(await detectGitRemoteRepo('/repo')).toBeUndefined(); diff --git a/src/utils/processes.ts b/src/utils/processes.ts index 1edf2205d..0b3a4e981 100644 --- a/src/utils/processes.ts +++ b/src/utils/processes.ts @@ -402,7 +402,7 @@ export async function detectGitRemoteRepo(cwd: string): Promise