Skip to content

Commit

Permalink
Merge pull request facebookarchive#51 from dflynn15/master
Browse files Browse the repository at this point in the history
feat: Changes user file glob an array
  • Loading branch information
vjeux committed Dec 4, 2015
2 parents 11e11f8 + 01a1dd3 commit a9afc6b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
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

0 comments on commit a9afc6b

Please sign in to comment.