Skip to content

Commit

Permalink
feat(bitbucket): main branch status for mend app dashboard
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Setch <[email protected]>
  • Loading branch information
setchy committed Nov 1, 2024
1 parent 6a39d49 commit 1a9eecc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
24 changes: 2 additions & 22 deletions lib/modules/platform/bitbucket/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,34 +277,14 @@ describe('modules/platform/bitbucket/index', () => {
uuid: '123',
full_name: 'some/repo',
})
.get('/2.0/repositories/some/repo/refs/branches/master')
.twice()
.reply(200, {
name: 'branch',
target: {
hash: 'branch_hash',
parents: [{ hash: 'master_hash' }],
},
})
.post('/2.0/repositories/some/repo/commit/branch_hash/statuses/build', {
.post('/2.0/repositories/some/repo/commit/HEAD/statuses/build', {
name: 'Renovate',
state: 'SUCCESSFUL',
key: 'Renovate',
description: 'Repository Dashboard',
url: 'https://developer.mend.io/bitbucket/some/repo',
})
.reply(200)
.get(
'/2.0/repositories/some/repo/commit/branch_hash/statuses?pagelen=100',
)
.reply(200, {
values: [
{
key: 'Renovate',
state: 'SUCCESSFUL',
},
],
});
.reply(200);

expect(
await bitbucket.initRepo({
Expand Down
22 changes: 21 additions & 1 deletion lib/modules/platform/bitbucket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export async function initRepo({

if (bbMendAppDashboardStatus) {
logger.debug('Creating branch status for Mend App Repository Dashboard');
await setBranchStatus({
await setHeadBranchStatus({
branchName: config.defaultBranch,
context: 'Renovate',
description: 'Repository Dashboard',
Expand Down Expand Up @@ -527,6 +527,26 @@ export async function setBranchStatus({
await getStatus(branchName, false);
}

async function setHeadBranchStatus({
context,
description,
state,
url,
}: BranchStatusConfig): Promise<void> {
const body = {
name: context,
state: utils.buildStates[state],
key: context,
description,
url,
};

await bitbucketHttp.postJson(
`/2.0/repositories/${config.repository}/commit/HEAD/statuses/build`,
{ body },
);
}

type BbIssue = { id: number; title: string; content?: { raw: string } };

async function findOpenIssues(title: string): Promise<BbIssue[]> {
Expand Down

0 comments on commit 1a9eecc

Please sign in to comment.