diff --git a/lib/getMergedPullRequests.js b/lib/getMergedPullRequests.js index d017bcc8..886e46b7 100644 --- a/lib/getMergedPullRequests.js +++ b/lib/getMergedPullRequests.js @@ -24,7 +24,7 @@ function getPullRequests(fromTag) { return commit.indexOf('Merge pull request') === 0; }) .map((pullRequest) => { - const pattern = /^Merge pull request #(\d+) from (.*) \((.*)\)/; + const pattern = /^Merge pull request #(\d+) from (.*?) \((.*)\)$/; const matches = pullRequest.match(pattern); return { diff --git a/test/unit/lib/getMergedPullRequestsSpec.js b/test/unit/lib/getMergedPullRequestsSpec.js index 2f4234a4..287b372e 100644 --- a/test/unit/lib/getMergedPullRequestsSpec.js +++ b/test/unit/lib/getMergedPullRequestsSpec.js @@ -105,4 +105,19 @@ describe('getMergedPullRequests', function () { return expect(getMergedPullRequests(anyRepo)) .to.become(expectedResults); }); + + it('should work with parentheses in the commit message body', function () { + const gitLogMessages = [ + 'Merge pull request #42 from A (pr-42 message (fixes #21))' + ]; + + const expectedResults = [ + { id: '42', title: 'pr-42 message (fixes #21)', label: 'bug' } + ]; + + gitLog.resolves(gitLogMessages.join('\n')); + + return expect(getMergedPullRequests(anyRepo)) + .to.become(expectedResults); + }); });