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

feat: Changes user file glob an array #51

Merged
merged 1 commit into from
Dec 4, 2015
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
2 changes: 1 addition & 1 deletion CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"alwaysNotifyForPaths": [
{
"name": "ghuser", // The user's Github username
"files": "src/js/**/*.js" // The file glob associated with the user
"files": ["src/js/**/*.js"] // The array of file globs associated with the user
}
], // users will always be mentioned based on file glob
"userBlacklist": [] // users in this list will never be mentioned by mention-bot
Expand Down
2 changes: 1 addition & 1 deletion __tests__/github-mention-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('Github Mention', function() {
alwaysNotifyForPaths: [
{
name: 'ghuser',
files: '**/*.js'
files: ['package.json', '**/*.js', 'README.md']
}
]
}
Expand Down
12 changes: 9 additions & 3 deletions mention-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type FileInfo = {

type WhitelistUser = {
name: string,
files: string
files: Array<string>
};

function startsWith(str, start) {
Expand Down Expand Up @@ -235,8 +235,14 @@ function getDefaultOwners(
var users = whitelist || [];

users.forEach(function(user) {
var userHasChangedFile = files.find(function(file) {
return minimatch(file.path, user.files);
let userHasChangedFile = false;

user.files.forEach(function(pattern) {
if (!userHasChangedFile) {
userHasChangedFile = files.find(function(file) {
return minimatch(file.path, pattern);
});
}
});

if (userHasChangedFile && owners.indexOf(user.name) === -1) {
Expand Down