Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Allow withLabel to be a list #181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The bot can be configured by adding a `.mention-bot` file to the base directory
"skipAlreadyMentionedPR": false, // mention-bot will ignore if there is already existing an exact mention
"assignToReviewer": false, // mention-bot assigns the most appropriate reviewer for PR
"skipTitle": "", // mention-bot will ignore PR that includes text in the title,
"withLabel": "", // mention-bot will only consider PR's with this label. Must set actions to ["labeled"].
"withLabel": "", // Can either be a single label or a list. mention-bot will only consider PR's with any of the labels specified. Must set actions to ["labeled"].
"delayed": false, // mention-bot will wait to comment until specified time in `delayedUntil` value
"delayedUntil": "3d", // Used if delayed is equal true, permitted values are: minutes, hours, or days, e.g.: '3 days', '40 minutes', '1 hour', '3d', '1h', '10m'
"skipCollaboratorPR": false, // mention-bot will ignore if PR is made by collaborator
Expand Down
20 changes: 15 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async function work(body) {
withLabel: '',
skipCollaboratorPR: false,
};

if (process.env.MENTION_BOT_CONFIG) {
try {
repoConfig = {
Expand Down Expand Up @@ -184,10 +184,20 @@ async function work(body) {
return false;
}

if (repoConfig.withLabel && data.label &&
data.label.name != repoConfig.withLabel) {
console.log('Skipping because pull request does not have label: ' + repoConfig.withLabel);
return false;
const withLabel: Array<string> | string = repoConfig.withLabel;
if (withLabel && data.label && data.label.name) {
if (typeof(withLabel) === 'array') {
if (withLabel.indexOf(data.label) === -1) {
console.log('Skipping because pull request does not ' +
'have any of the labels: ' + withLabel.join(', '));
return false;
}
}
else if (data.label.name != withLabel) {
console.log('Skipping because pull request does not have ' +
'label: ' + withLabel);
return false;
}
}

if (repoConfig.skipTitle &&
Expand Down