mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 06:26:26 +00:00
fix(bitbucket): source link root path (#32689)
Signed-off-by: Adam Setch <adam.setch@outlook.com>
This commit is contained in:
parent
231ee54f0e
commit
c4f4934701
2 changed files with 35 additions and 3 deletions
|
@ -89,12 +89,21 @@ 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',
|
||||
sourceDirectory: '/baz',
|
||||
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 +137,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/src/HEAD/baz), [changelog](https://bitbucket.org/foo/bar/src/main/CHANGELOG.md))',
|
||||
references:
|
||||
'[homepage](https://example.com), [source](https://bitbucket.org/foo/bar/src/HEAD/baz), [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', () => {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import type { RenovateConfig } from '../../../../../config/types';
|
||||
import type { PrDebugData } from '../../../../../modules/platform';
|
||||
import { platform } from '../../../../../modules/platform';
|
||||
import { detectPlatform } from '../../../../../util/common';
|
||||
import { regEx } from '../../../../../util/regex';
|
||||
import { toBase64 } from '../../../../../util/string';
|
||||
import * as template from '../../../../../util/template';
|
||||
|
@ -31,12 +32,20 @@ function massageUpdateMetadata(config: BranchConfig): void {
|
|||
depNameLinked = `[${depNameLinked}](${primaryLink})`;
|
||||
}
|
||||
|
||||
let sourceRootPath = 'tree';
|
||||
if (sourceUrl) {
|
||||
const sourcePlatform = detectPlatform(sourceUrl);
|
||||
if (sourcePlatform === 'bitbucket') {
|
||||
sourceRootPath = 'src';
|
||||
}
|
||||
}
|
||||
|
||||
const otherLinks = [];
|
||||
if (sourceUrl && (!!sourceDirectory || homepage)) {
|
||||
otherLinks.push(
|
||||
`[source](${
|
||||
sourceDirectory
|
||||
? joinUrlParts(sourceUrl, 'tree/HEAD/', sourceDirectory)
|
||||
? joinUrlParts(sourceUrl, sourceRootPath, 'HEAD', sourceDirectory)
|
||||
: sourceUrl
|
||||
})`,
|
||||
);
|
||||
|
@ -55,7 +64,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})`);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue