Skip to content

Commit

Permalink
Merge pull request #18 from rbmrclo/refactor/pull-requests-ignorable
Browse files Browse the repository at this point in the history
Improve pattern matching of title for ignorable PRs
  • Loading branch information
Masato Ohba committed Aug 15, 2017
2 parents c0e6547 + 9945d20 commit 7ecbd21
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/PullRequests.js
Expand Up @@ -12,9 +12,10 @@ class PullRequests {
}

isIgnorable(pr) {
const ignoreWords = ['wip', 'dont merge', 'dontmerge', 'donotmerge']
const ignoreWords = ['wip', 'dontmerge', 'donotmerge']
const regex = new RegExp(`(${ignoreWords.join('|')})`, 'i')
return !!pr.title.match(regex)
const sanitizedTitle = pr.title.replace(/'|\s+/g, '')
return !!sanitizedTitle.match(regex)
}

belongsToOwner(pr) {
Expand Down
16 changes: 16 additions & 0 deletions test/PullRequests.test.js
@@ -0,0 +1,16 @@
const PullRequests = require('../src/PullRequests')

test('.isIgnorable(pr) returns true with matched strings', () => {
const pullRequest = new PullRequests()
const pullRequests = [
{ title: "Dont merge - this is a PR title" },
{ title: "Don't merge - this is a PR title" },
{ title: "Do not merge - this is a PR title" },
{ title: "[DO NOT MERGE] - this is a PR title" },
{ title: "WIP - this is a PR title" },
]

for (const pr of pullRequests) {
expect(pullRequest.isIgnorable(pr)).toBeTruthy()
}
})

0 comments on commit 7ecbd21

Please sign in to comment.