diff --git a/docs/pre-release.md b/docs/pre-release.md index 54a6f9016cec20ae3dafdc3eef8fe9d0163f263b..1d4786217e675c1c34f8fc144457948a595d0a67 100644 --- a/docs/pre-release.md +++ b/docs/pre-release.md @@ -14,7 +14,7 @@ As a general guide: Status: beta -Bitbucket Cloud support (i.e. [https://bitbucket.org](https://bitbucket.org)) is still missing some nice-to-have features (reviewers, issues, etc) but none of these have to hold it back from being considered GA. Mostly, we'd just like to get some more feedback from users who have been testing it. +Bitbucket Cloud support (i.e. [https://bitbucket.org](https://bitbucket.org)) is still missing some nice-to-have features (issues, etc) but none of these have to hold it back from being considered GA. Mostly, we'd just like to get some more feedback from users who have been testing it. Note: we plan to add support for Bitbucket.org to the _hosted_ Renovate Bot _service_ that already supports GitHub.com and GitLab.com, so you won't need to run your own bot unless you want to. diff --git a/lib/config/definitions.js b/lib/config/definitions.js index f1501964130df2ee4d25427152fa752e86125296..1adad16620fab764beb436ec12e85179fb6dce7f 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -1054,7 +1054,7 @@ const options = [ { name: 'reviewers', description: - 'Requested reviewers for Pull Requests (username in GitHub/GitLab, email or username in Azure DevOps)', + 'Requested reviewers for Pull Requests (username in GitHub/GitLab/Bitbucket, email or username in Azure DevOps)', type: 'array', subType: 'string', }, diff --git a/lib/platform/bitbucket/README.md b/lib/platform/bitbucket/README.md index f8e382c1d59d69b6725af8a2b17771bcb025a940..0821c528a073f6f2c328bb104bc1ee8c84c47cd7 100644 --- a/lib/platform/bitbucket/README.md +++ b/lib/platform/bitbucket/README.md @@ -9,5 +9,4 @@ Bitbucket Cloud support is considered in "beta" release status. Mostly, it just ## Features requiring implementation - Creating issues not implemented yet, e.g. when there is a config error -- Adding reviewers to PRs not implemented yet - Adding comments to PRs not implemented yet, e.g. when a PR has been edited or has a lockfile error diff --git a/lib/platform/bitbucket/index.js b/lib/platform/bitbucket/index.js index 3aed5de4083b239d862e5aec63814cb64d547eac..2b14cfe66eb41e5ff4d1ff2053eca542bffec7ed 100644 --- a/lib/platform/bitbucket/index.js +++ b/lib/platform/bitbucket/index.js @@ -385,10 +385,19 @@ function addAssignees() { return Promise.resolve(); } -function addReviewers() { - // TODO - logger.warn('Cannot add reviewers'); - return Promise.resolve(); +async function addReviewers(prId, reviewers) { + logger.debug(`Adding reviewers ${reviewers} to #${prId}`); + + const { title } = await getPr(prId); + + const body = { + title, + reviewers: reviewers.map(username => ({ username })), + }; + + await api.put(`/2.0/repositories/${config.repository}/pullrequests/${prId}`, { + body, + }); } // istanbul ignore next diff --git a/renovate-schema.json b/renovate-schema.json index 3d6bd6eaa1a35a56423ef0b2db83f36519ac4da5..f0eb6d2035f36fc925cf0e02e5958ca7bea55a77 100644 --- a/renovate-schema.json +++ b/renovate-schema.json @@ -700,7 +700,7 @@ } }, "reviewers": { - "description": "Requested reviewers for Pull Requests (username in GitHub/GitLab, email or username in Azure DevOps)", + "description": "Requested reviewers for Pull Requests (username in GitHub/GitLab/Bitbucket, email or username in Azure DevOps)", "type": "array", "items": { "type": "string" diff --git a/test/platform/bitbucket/__snapshots__/index.spec.js.snap b/test/platform/bitbucket/__snapshots__/index.spec.js.snap index 5e96ff697ae9d7cf305c91d0d9a53568e3ce3d07..0c21d78b57f08d575fa39eef303630ce770b61f2 100644 --- a/test/platform/bitbucket/__snapshots__/index.spec.js.snap +++ b/test/platform/bitbucket/__snapshots__/index.spec.js.snap @@ -1,5 +1,26 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`platform/bitbucket addReviewers should add the given reviewers to the PR 1`] = ` +Array [ + Array [ + "/2.0/repositories/some/repo/pullrequests/5", + Object { + "body": Object { + "reviewers": Array [ + Object { + "username": "someuser", + }, + Object { + "username": "someotheruser", + }, + ], + "title": "title", + }, + }, + ], +] +`; + exports[`platform/bitbucket createPr() posts PR 1`] = ` Array [ Array [ diff --git a/test/platform/bitbucket/index.spec.js b/test/platform/bitbucket/index.spec.js index 8a00fd2e156522f81cc9fe534e808d64efbcbd31..5f8bde363efb4685458c04fafda0a1c443cf6b86 100644 --- a/test/platform/bitbucket/index.spec.js +++ b/test/platform/bitbucket/index.spec.js @@ -288,8 +288,12 @@ describe('platform/bitbucket', () => { }); describe('addReviewers', () => { - it('does not throw', async () => { - await bitbucket.addReviewers(5, ['some']); + it('should add the given reviewers to the PR', async () => { + await initRepo(); + await mocked(async () => { + await bitbucket.addReviewers(5, ['someuser', 'someotheruser']); + expect(api.put.mock.calls).toMatchSnapshot(); + }); }); });