From d4e5996894a8416844055b122655ae8d0f08fbb9 Mon Sep 17 00:00:00 2001 From: Gabriel Lavoie <glavoie@gmail.com> Date: Thu, 27 Jun 2019 07:53:25 -0400 Subject: [PATCH] feat(github): Support for team assignment. (#3973) --- lib/platform/github/index.js | 9 ++++++++- test/platform/github/__snapshots__/index.spec.js.snap | 3 +++ test/platform/github/index.spec.js | 6 +++++- website/docs/configuration-options.md | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 1e7b035ffb..f2ff4ccae7 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -866,12 +866,19 @@ async function addAssignees(issueNo, assignees) { async function addReviewers(prNo, reviewers) { logger.debug(`Adding reviewers ${reviewers} to #${prNo}`); + + const userReviewers = reviewers.filter(e => !e.startsWith('team:')); + const teamReviewers = reviewers + .filter(e => e.startsWith('team:')) + .map(e => e.replace(/^team:/, '')); + await get.post( `repos/${config.parentRepo || config.repository}/pulls/${prNo}/requested_reviewers`, { body: { - reviewers, + reviewers: userReviewers, + team_reviewers: teamReviewers, }, } ); diff --git a/test/platform/github/__snapshots__/index.spec.js.snap b/test/platform/github/__snapshots__/index.spec.js.snap index bef71803ec..96b73e6303 100644 --- a/test/platform/github/__snapshots__/index.spec.js.snap +++ b/test/platform/github/__snapshots__/index.spec.js.snap @@ -26,6 +26,9 @@ Array [ "someuser", "someotheruser", ], + "team_reviewers": Array [ + "someteam", + ], }, }, ], diff --git a/test/platform/github/index.spec.js b/test/platform/github/index.spec.js index c0d6582f2e..50b0b0fdd9 100644 --- a/test/platform/github/index.spec.js +++ b/test/platform/github/index.spec.js @@ -1050,7 +1050,11 @@ describe('platform/github', () => { repository: 'some/repo', }); get.post.mockReturnValueOnce({}); - await github.addReviewers(42, ['someuser', 'someotheruser']); + await github.addReviewers(42, [ + 'someuser', + 'someotheruser', + 'team:someteam', + ]); expect(get.post.mock.calls).toMatchSnapshot(); }); }); diff --git a/website/docs/configuration-options.md b/website/docs/configuration-options.md index a1cbbe890b..75df35c4a5 100644 --- a/website/docs/configuration-options.md +++ b/website/docs/configuration-options.md @@ -976,7 +976,7 @@ Similar to `ignoreUnstable`, this option controls whether to update to versions ## reviewers -Must be valid usernames. Note: does not currently work with the GitHub App due to an outstanding GitHub API bug. +Must be valid usernames. If on GitHub and assigning a team to review, use the prefix `team:`, e.g. provide a value like `team:someteam`. ## rollbackPrs -- GitLab