feat(bitbucket): Enable bitbucket reviewers (#3509)

feat(bitbucket): Enable bitbucket reviewers
This commit is contained in:
Matt Lavin 2019-04-09 09:46:40 -04:00 коммит произвёл Rhys Arkins
Родитель 56ea312970
Коммит 47e8dd9ac2
7 изменённых файлов: 43 добавлений и 10 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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',
},

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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"

Просмотреть файл

@ -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 [

Просмотреть файл

@ -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();
});
});
});