Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hard-coded teams #12

Merged
merged 1 commit into from
Aug 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions message.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = function(
reviewers: Array<string>,
pullRequester: string,
mentionSentenceBuilder: (reviewers: Array<string>) => string,
defaultMessageGenerator: (reviewers: Array<string>, pullRequester: string) => string
defaultMessageGenerator: (reviewers: Array<string>, pullRequester: string) => string,
assignee: string
): string {

// This file is a place where you can change the way the message the bot
Expand All @@ -28,5 +29,5 @@ module.exports = function(
//
// @hunkim, thanks! @georgecodes and @vjeux, please review this.

return defaultMessageGenerator(reviewers, pullRequester);
return defaultMessageGenerator(reviewers, pullRequester, assignee);
};
46 changes: 40 additions & 6 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ github.authenticate({

var app = express();

var dlangReviewers = {
"dlang/dmd": ["WalterBright", "MartinNowak", "yebblies", "AndrejMitrovic", "klickverbot", "9rnsr",
"andralex"],
"dlang/druntime": ["WalterBright", "MartinNowak", "yebblies", "AndrejMitrovic", "klickverbot", "9rnsr",
"andralex", "DmitryOlshansky", "jmdavis", "rainers", "schveiguy", "CyberShadow"],
"dlang/phobos": ["WalterBright", "MartinNowak", "yebblies", "AndrejMitrovic", "klickverbot", "9rnsr",
"andralex", "DmitryOlshansky", "jmdavis", "rainers", "schveiguy", "9il", "CyberShadow",
"Hackerpilot", "quickfur", "wilzbach"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add my name to it as well

}

function buildMentionSentence(reviewers) {
var atReviewers = reviewers.map(function(owner) { return '@' + owner; });

Expand All @@ -76,7 +86,7 @@ function buildMentionSentence(reviewers) {
);
}

function defaultMessageGenerator(reviewers, pullRequester) {
function defaultMessageGenerator(reviewers, pullRequester, assignee) {
return util.format(
'%s, thanks for your PR! ' +
'By analyzing the annotation information on this pull request' +
Expand All @@ -89,11 +99,11 @@ function defaultMessageGenerator(reviewers, pullRequester) {
buildMentionSentence(reviewers),
reviewers.length > 1 ? '' : ' a',
reviewers.length > 1 ? 's' : '',
reviewers[0]
assignee
);
}

function configMessageGenerator(message, reviewers, pullRequester) {
function configMessageGenerator(message, reviewers, pullRequester, assignee) {
var withReviewers = message.replace(/@reviewers/g, buildMentionSentence(reviewers));
return withReviewers.replace(/@pullRequester/g, pullRequester);
}
Expand Down Expand Up @@ -249,19 +259,43 @@ async function work(body) {
return;
}

// use hard-coded reviewers for Phobos
var assignee;
if (dlangReviewers[data.repository.full_name])
{
var potentialReviewers = dlangReviewers[data.repository.full_name];
for (var i = 0; i < reviewers.length; i++)
{
if (potentialReviewers.indexOf(reviewers[i]) >= 0)
{
assignee = reviewers[i];
break;
}
};
}
// otherwise apply good luck and go with the first one
if (typeof(assignee) == "undefined")
{
assignee = reviewers[0];
}

console.log('Assignee: ', assignee);

var message = null;
if (repoConfig.message) {
message = configMessageGenerator(
repoConfig.message,
reviewers,
'@' + data.pull_request.user.login
'@' + data.pull_request.user.login,
assignee
);
} else {
message = messageGenerator(
reviewers,
'@' + data.pull_request.user.login, // pull-requester
buildMentionSentence,
defaultMessageGenerator
defaultMessageGenerator,
assignee
);
}

Expand Down Expand Up @@ -354,7 +388,7 @@ async function work(body) {
} else {
createComment(data, message);
// for now we only pick the best matching reviewer
assignReviewer(data, reviewers.slice(0, 1));
assignReviewer(data, [assignee]);
}

return;
Expand Down