diff --git a/public/app/features/provisioning/components/utils/url.ts b/public/app/features/provisioning/components/utils/url.ts index 4675600044c..8a5b5316349 100644 --- a/public/app/features/provisioning/components/utils/url.ts +++ b/public/app/features/provisioning/components/utils/url.ts @@ -15,6 +15,10 @@ export const getBranchUrl = (baseUrl: string, branch: string, repoType?: string) return `${cleanBaseUrl}/-/tree/${branch}`; case 'bitbucket': return `${cleanBaseUrl}/src/${branch}`; + case 'git': + // Generic git repositories don't have a standard URL pattern for branches + // Just return the base URL without branch segment + return cleanBaseUrl; default: return ''; } diff --git a/public/app/features/provisioning/utils/git.test.ts b/public/app/features/provisioning/utils/git.test.ts index 05c0eef90ec..18c4b01dc0f 100644 --- a/public/app/features/provisioning/utils/git.test.ts +++ b/public/app/features/provisioning/utils/git.test.ts @@ -127,7 +127,7 @@ describe('buildRepoUrl', () => { ).toBe('https://bitbucket.org/workspace/repo/src/main'); }); - it('builds generic git href with tree segment', () => { + it('builds generic git href without tree segment', () => { expect( getRepoHrefForProvider( spec({ @@ -135,7 +135,7 @@ describe('buildRepoUrl', () => { git: { url: 'https://git.example.com/owner/repo.git', branch: 'main' }, }) ) - ).toBe('https://git.example.com/owner/repo/tree/main'); + ).toBe('https://git.example.com/owner/repo'); }); }); diff --git a/public/app/features/provisioning/utils/git.ts b/public/app/features/provisioning/utils/git.ts index 51c26239fbe..1e169601684 100644 --- a/public/app/features/provisioning/utils/git.ts +++ b/public/app/features/provisioning/utils/git.ts @@ -102,12 +102,9 @@ export const getRepoHrefForProvider = (spec?: RepositorySpec) => { path: spec.bitbucket?.path, }); case 'git': - return buildRepoUrl({ - baseUrl: spec.git?.url, - branch: spec.git?.branch, - providerSegments: ['tree'], - path: spec.git?.path, - }); + // Generic git repositories don't have a standard URL pattern + // Just return the base URL without branch/path segments + return spec.git?.url ? buildCleanBaseUrl(spec.git.url) : undefined; default: return undefined; }