Skip to content

Commit 2eafcb4

Browse files
[owners] Disable automatic assignment of PRs to owners (#2492)
1 parent a6cd7e9 commit 2eafcb4

File tree

8 files changed

+1
-1020
lines changed

8 files changed

+1
-1020
lines changed

owners/src/api/github.js

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -292,29 +292,6 @@ class GitHub {
292292
);
293293
}
294294

295-
/**
296-
* Requests a review from GitHub users.
297-
*
298-
* @param {number} number PR number.
299-
* @param {!Array<string>} reviewers the list of usernames to request reviews from.
300-
*/
301-
async createReviewRequests(number, reviewers) {
302-
if (!reviewers.length) {
303-
this.logger.warn(
304-
`Attempted to request reviews for PR ${number} ` +
305-
'but provided an empty username list'
306-
);
307-
return;
308-
}
309-
this.logger.info(
310-
`Requesting review for PR #${number} from: ${reviewers.join(', ')}`
311-
);
312-
313-
await this.client.pulls.requestReviewers(
314-
this.repo({'pull_number': number, reviewers})
315-
);
316-
}
317-
318295
/**
319296
* Retrieves code review requests for a PR from GitHub.
320297
*
@@ -332,83 +309,6 @@ class GitHub {
332309
return response.data.users.map(({login}) => login.toLowerCase());
333310
}
334311

335-
/**
336-
* Retrieves PR comments by the bot user.
337-
*
338-
* Note that pull request comments fall under the Issues API, while comments
339-
* created via the Pulls API require a file path/position.
340-
*
341-
* @param {number} number PR number.
342-
* @return {!Array<{body: string, id: number}>} list of comments by the bot.
343-
*/
344-
async getBotComments(number) {
345-
this.logger.info(`Fetching bot comments for PR #${number}`);
346-
347-
const comments = await this._paginate(
348-
this.client.issues.listComments,
349-
this.repo({'issue_number': number})
350-
);
351-
this.logger.debug('[getBotComments]', number, comments);
352-
353-
// GitHub appears to respond with the bot's username suffixed by `[bot]`,
354-
// though this doesn't appear to be documented anywhere. Since it's not
355-
// documented, rather than testing for that suffix explicitly, we just test
356-
// for the presence of the username and ignore whatever extras GitHub tacks
357-
// on.
358-
const regex = new RegExp(`\\b${process.env.GITHUB_BOT_USERNAME}\\b`);
359-
return comments
360-
.filter(({user}) => regex.test(user.login))
361-
.map(({id, body}) => {
362-
return {id, body};
363-
});
364-
}
365-
366-
/**
367-
* Creates a comment on a PR.
368-
*
369-
* Note that pull request comments fall under the Issues API, while comments
370-
* created via the Pulls API require a file path/position.
371-
*
372-
* @param {number} number PR number.
373-
* @param {string} body comment body.
374-
* @return {Object} API response
375-
*/
376-
async createBotComment(number, body) {
377-
this.logger.info(`Adding bot comment to PR #${number}`);
378-
this.logger.debug('[createBotComment]', number, body);
379-
380-
const {data} = await this._customRequest(
381-
'POST',
382-
`/repos/${this.owner}/${this.repository}/issues/${number}/comments`,
383-
{body}
384-
);
385-
386-
return data;
387-
}
388-
389-
/**
390-
* Updates a comment on a PR.
391-
*
392-
* Note that pull request comments fall under the Issues API, while comments
393-
* created via the Pulls API require a file path/position.
394-
*
395-
* @param {number} commentId ID of comment to update.
396-
* @param {string} body comment body.
397-
* @return {Object} API response
398-
*/
399-
async updateComment(commentId, body) {
400-
this.logger.info(`Replacing comment with ID ${commentId}`);
401-
this.logger.debug('[updateComment]', commentId, body);
402-
403-
const {data} = await this._customRequest(
404-
'PATCH',
405-
`/repos/${this.owner}/${this.repository}/issues/comments/${commentId}`,
406-
{body}
407-
);
408-
409-
return data;
410-
}
411-
412312
/**
413313
* Fetches the contents of a file from GitHub.
414314
*

owners/src/notifier.js

Lines changed: 0 additions & 205 deletions
This file was deleted.

owners/src/owners_bot.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
const OwnersTree = require('./ownership/tree');
1818
const sleep = require('sleep-promise');
1919
const {OwnersCheck} = require('./ownership/owners_check');
20-
const {OwnersNotifier} = require('./notifier');
2120
const {OwnersParser} = require('./ownership/parser');
2221

2322
const GITHUB_CHECKRUN_DELAY = 2000;
@@ -123,9 +122,8 @@ class OwnersBot {
123122
*
124123
* @param {!GitHub} github GitHub API interface.
125124
* @param {!PullRequest} pr pull request to run owners check on.
126-
* @param {?boolean} requestOwners request reviews from owners.
127125
*/
128-
async runOwnersCheck(github, pr, requestOwners = false) {
126+
async runOwnersCheck(github, pr) {
129127
if (!pr.isOpen) {
130128
return;
131129
}
@@ -146,12 +144,6 @@ class OwnersBot {
146144
await sleep(this.GITHUB_CHECKRUN_DELAY);
147145
await github.createCheckRun(pr.headSha, ownersCheck.checkRun);
148146
}
149-
150-
const suggestedReviewers = requestOwners ? ownersCheck.reviewers : [];
151-
await new OwnersNotifier(pr, reviewers, tree, changedFiles).notify(
152-
github,
153-
suggestedReviewers
154-
);
155147
}
156148

157149
/**

0 commit comments

Comments
 (0)