mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-10 14:06:30 +00:00
Merge 02b53c1f33
into 1d2c1a35e3
This commit is contained in:
commit
d0ead23ab4
5 changed files with 165 additions and 1 deletions
|
@ -346,6 +346,10 @@ You can also use the special `"$default"` string to denote the repository's defa
|
|||
|
||||
Configuring this to `true` means that Renovate will mark all PR Tasks as complete.
|
||||
|
||||
## bbMendAppDashboardStatus
|
||||
|
||||
Configure this to `true` means that Renovate will create a branch status against the repository's main branch, linking to the [Mend App on Bitbucket Repository Dashboard](./mend-hosted/hosted-apps-config.md).
|
||||
|
||||
## bbUseDefaultReviewers
|
||||
|
||||
Configuring this to `true` means that Renovate will detect and apply the default reviewers rules to PRs (Bitbucket only).
|
||||
|
|
|
@ -1951,6 +1951,13 @@ const options: RenovateOptions[] = [
|
|||
default: false,
|
||||
supportedPlatforms: ['bitbucket'],
|
||||
},
|
||||
{
|
||||
name: 'bbMendAppDashboardStatus',
|
||||
description: `Creates a main branch status linked to the repository's Mend App Dashboard.`,
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
supportedPlatforms: ['bitbucket'],
|
||||
},
|
||||
{
|
||||
name: 'bbUseDefaultReviewers',
|
||||
description: 'Use the default reviewers (Bitbucket only).',
|
||||
|
|
|
@ -246,6 +246,134 @@ describe('modules/platform/bitbucket/index', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('bbMendAppDashboardStatus', () => {
|
||||
it('not enabled: should skip setting branch status for main branch', async () => {
|
||||
httpMock
|
||||
.scope(baseUrl)
|
||||
.get('/2.0/repositories/some/repo')
|
||||
.reply(200, {
|
||||
mainbranch: { name: 'main' },
|
||||
uuid: '123',
|
||||
full_name: 'some/repo',
|
||||
});
|
||||
|
||||
expect(
|
||||
await bitbucket.initRepo({
|
||||
repository: 'some/repo',
|
||||
bbMendAppDashboardStatus: false,
|
||||
}),
|
||||
).toMatchObject({
|
||||
defaultBranch: 'main',
|
||||
isFork: false,
|
||||
repoFingerprint: expect.any(String),
|
||||
});
|
||||
});
|
||||
|
||||
it('enabled: should set main branch status if does not exist', async () => {
|
||||
httpMock
|
||||
.scope(baseUrl)
|
||||
.get('/2.0/repositories/some/repo')
|
||||
.reply(200, {
|
||||
mainbranch: { name: 'main' },
|
||||
uuid: '123',
|
||||
full_name: 'some/repo',
|
||||
})
|
||||
.get('/2.0/repositories/some/repo/refs/branches/main')
|
||||
.thrice()
|
||||
.reply(200, {
|
||||
name: 'main',
|
||||
target: {
|
||||
hash: 'main_hash',
|
||||
},
|
||||
})
|
||||
.post('/2.0/repositories/some/repo/commit/main_hash/statuses/build', {
|
||||
name: 'Mend.io Dashboard',
|
||||
state: 'SUCCESSFUL',
|
||||
key: 'Mend.io Dashboard',
|
||||
description: '',
|
||||
url: 'https://developer.mend.io/bitbucket/some/repo',
|
||||
})
|
||||
.reply(200)
|
||||
.get(
|
||||
'/2.0/repositories/some/repo/commit/main_hash/statuses?pagelen=100',
|
||||
)
|
||||
.reply(200, {
|
||||
values: [
|
||||
{
|
||||
key: 'Some other status',
|
||||
state: 'SUCCESSFUL',
|
||||
},
|
||||
],
|
||||
})
|
||||
.get(
|
||||
'/2.0/repositories/some/repo/commit/main_hash/statuses?pagelen=100',
|
||||
)
|
||||
.reply(200, {
|
||||
values: [
|
||||
{
|
||||
key: 'Some other status',
|
||||
state: 'SUCCESSFUL',
|
||||
},
|
||||
{
|
||||
key: 'Mend.io Dashboard',
|
||||
state: 'SUCCESSFUL',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(
|
||||
await bitbucket.initRepo({
|
||||
repository: 'some/repo',
|
||||
bbMendAppDashboardStatus: true,
|
||||
}),
|
||||
).toMatchObject({
|
||||
defaultBranch: 'main',
|
||||
isFork: false,
|
||||
repoFingerprint: expect.any(String),
|
||||
});
|
||||
});
|
||||
|
||||
it('enabled: should skip creating main branch status if already exist', async () => {
|
||||
httpMock
|
||||
.scope(baseUrl)
|
||||
.get('/2.0/repositories/some/repo')
|
||||
.reply(200, {
|
||||
mainbranch: { name: 'main' },
|
||||
uuid: '123',
|
||||
full_name: 'some/repo',
|
||||
})
|
||||
.get('/2.0/repositories/some/repo/refs/branches/main')
|
||||
.reply(200, {
|
||||
name: 'main',
|
||||
target: {
|
||||
hash: 'main_hash',
|
||||
},
|
||||
})
|
||||
.get(
|
||||
'/2.0/repositories/some/repo/commit/main_hash/statuses?pagelen=100',
|
||||
)
|
||||
.reply(200, {
|
||||
values: [
|
||||
{
|
||||
key: 'Mend.io Dashboard',
|
||||
state: 'SUCCESSFUL',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(
|
||||
await bitbucket.initRepo({
|
||||
repository: 'some/repo',
|
||||
bbMendAppDashboardStatus: true,
|
||||
}),
|
||||
).toMatchObject({
|
||||
defaultBranch: 'main',
|
||||
isFork: false,
|
||||
repoFingerprint: expect.any(String),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('bbUseDevelopmentBranch', () => {
|
||||
it('not enabled: defaults to using main branch', async () => {
|
||||
httpMock
|
||||
|
|
|
@ -187,6 +187,7 @@ export async function initRepo({
|
|||
cloneSubmodules,
|
||||
cloneSubmodulesFilter,
|
||||
ignorePrAuthor,
|
||||
bbMendAppDashboardStatus,
|
||||
bbUseDevelopmentBranch,
|
||||
}: RepoParams): Promise<RepoResult> {
|
||||
logger.debug(`initRepo("${repository}")`);
|
||||
|
@ -224,6 +225,27 @@ export async function initRepo({
|
|||
|
||||
config.defaultBranch = mainBranch;
|
||||
|
||||
if (bbMendAppDashboardStatus) {
|
||||
const statusName = 'Mend.io Dashboard';
|
||||
|
||||
const mendAppDashboardStatus = await getBranchStatusCheck(
|
||||
config.defaultBranch,
|
||||
statusName,
|
||||
);
|
||||
|
||||
if (!mendAppDashboardStatus) {
|
||||
logger.debug(`Creating branch status for ${statusName}`);
|
||||
|
||||
await setBranchStatus({
|
||||
branchName: config.defaultBranch,
|
||||
context: statusName,
|
||||
description: '',
|
||||
state: 'green',
|
||||
url: `https://developer.mend.io/bitbucket/${repository}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
config = {
|
||||
...config,
|
||||
owner: info.owner,
|
||||
|
@ -433,6 +455,7 @@ async function getStatus(
|
|||
)
|
||||
).body.values;
|
||||
}
|
||||
|
||||
// Returns the combined status for a branch.
|
||||
export async function getBranchStatus(
|
||||
branchName: string,
|
||||
|
|
|
@ -49,6 +49,7 @@ export interface RepoParams {
|
|||
cloneSubmodules?: boolean;
|
||||
cloneSubmodulesFilter?: string[];
|
||||
ignorePrAuthor?: boolean;
|
||||
bbMendAppDashboardStatus?: boolean;
|
||||
bbUseDevelopmentBranch?: boolean;
|
||||
includeMirrors?: boolean;
|
||||
}
|
||||
|
@ -101,8 +102,9 @@ export type PlatformPrOptions = {
|
|||
autoApprove?: boolean;
|
||||
automergeStrategy?: MergeStrategy;
|
||||
azureWorkItemId?: number;
|
||||
bbUseDefaultReviewers?: boolean;
|
||||
bbAutoResolvePrTasks?: boolean;
|
||||
bbMendAppDashboardStatus?: boolean;
|
||||
bbUseDefaultReviewers?: boolean;
|
||||
gitLabIgnoreApprovals?: boolean;
|
||||
usePlatformAutomerge?: boolean;
|
||||
forkModeDisallowMaintainerEdits?: boolean;
|
||||
|
|
Loading…
Reference in a new issue