diff --git a/lib/workers/repository/update/pr/body/index.spec.ts b/lib/workers/repository/update/pr/body/index.spec.ts index eb5149a2685a1f..64bcc33f3c5ac6 100644 --- a/lib/workers/repository/update/pr/body/index.spec.ts +++ b/lib/workers/repository/update/pr/body/index.spec.ts @@ -89,12 +89,20 @@ describe('workers/repository/update/pr/body/index', () => { homepage: 'https://example.com', }; + const upgradeBitbucket = { + manager: 'some-manager', + branchName: 'some-branch', + sourceUrl: 'https://bitbucket.org/foo/bar', + changelogUrl: 'https://bitbucket.org/foo/bar/src/main/CHANGELOG.md', + homepage: 'https://example.com', + }; + getPrBody( { manager: 'some-manager', baseBranch: 'base', branchName: 'some-branch', - upgrades: [upgrade, upgrade1], + upgrades: [upgrade, upgrade1, upgradeBitbucket], }, { debugData: { @@ -128,6 +136,15 @@ describe('workers/repository/update/pr/body/index', () => { homepage: 'https://example.com', sourceUrl: 'https://github.com/foo/bar', }); + expect(upgradeBitbucket).toMatchObject({ + branchName: 'some-branch', + depNameLinked: + '[undefined](https://example.com) ([source](https://bitbucket.org/foo/bar), [changelog](https://bitbucket.org/foo/bar/src/main/CHANGELOG.md))', + references: + '[homepage](https://example.com), [source](https://bitbucket.org/foo/bar), [changelog](https://bitbucket.org/foo/bar/src/main/CHANGELOG.md)', + homepage: 'https://example.com', + sourceUrl: 'https://bitbucket.org/foo/bar', + }); }); it('uses dependencyUrl as primary link', () => { diff --git a/lib/workers/repository/update/pr/body/index.ts b/lib/workers/repository/update/pr/body/index.ts index 1c1e5d8d1f9e88..e0e4032fe0e362 100644 --- a/lib/workers/repository/update/pr/body/index.ts +++ b/lib/workers/repository/update/pr/body/index.ts @@ -31,12 +31,14 @@ function massageUpdateMetadata(config: BranchConfig): void { depNameLinked = `[${depNameLinked}](${primaryLink})`; } + const sourceRootPath = getSourceRootPath(sourceUrl); + const otherLinks = []; if (sourceUrl && (!!sourceDirectory || homepage)) { otherLinks.push( `[source](${ sourceDirectory - ? joinUrlParts(sourceUrl, 'tree/HEAD/', sourceDirectory) + ? joinUrlParts(sourceUrl, sourceRootPath, 'HEAD', sourceDirectory) : sourceUrl })`, ); @@ -55,7 +57,12 @@ function massageUpdateMetadata(config: BranchConfig): void { if (sourceUrl) { let fullUrl = sourceUrl; if (sourceDirectory) { - fullUrl = joinUrlParts(sourceUrl, 'tree/HEAD/', sourceDirectory); + fullUrl = joinUrlParts( + sourceUrl, + sourceRootPath, + 'HEAD', + sourceDirectory, + ); } references.push(`[source](${fullUrl})`); } @@ -66,6 +73,14 @@ function massageUpdateMetadata(config: BranchConfig): void { }); } +function getSourceRootPath(sourceUrl: string) { + if (sourceUrl.startsWith('https://bitbucket.org/')) { + return 'src'; + } + + return 'tree'; +} + interface PrBodyConfig { appendExtra?: string | null | undefined; rebasingNotice?: string;