Skip to content

Commit

Permalink
Fix crash with mulitline commit message body
Browse files Browse the repository at this point in the history
  • Loading branch information
lo1tuma committed Mar 7, 2015
1 parent 14573f6 commit ed60fbe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/getMergedPullRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getLatestVersionTag() {
function getPullRequests(fromTag) {
return git('log --no-color --pretty=format:"%s (%b)" --merges ' + fromTag + '..HEAD')
.then(function (result) {
var mergeCommits = result.split('\n');
var mergeCommits = result.replace(/[\r\n]+\)/g, ')').split('\n');

return mergeCommits
.filter(function (commit) {
Expand Down
17 changes: 17 additions & 0 deletions test/unit/lib/getMergedPullRequestsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var chai = require('chai'),

require('sinon-as-promised');
chai.use(require('sinon-chai'));
chai.use(require('chai-as-promised'));

describe('getMergedPullRequests', function () {
var getPullRequestLabel = sinon.stub(),
Expand Down Expand Up @@ -83,4 +84,20 @@ describe('getMergedPullRequests', function () {
expect(pullRequests).to.deep.equal(expectedPullRequests);
});
});

it('should work with line feeds in commit message body', function () {
var gitLogMessages = [
'Merge pull request #1 from A (pr-1 message\n)',
'Merge pull request #2 from B (pr-2 message)'
],
expectedResults = [
{ id: '1', title: 'pr-1 message', label: 'bug' },
{ id: '2', title: 'pr-2 message', label: 'bug' }
];

gitLog.resolves(gitLogMessages.join('\n'));

return expect(getMergedPullRequests(anyRepo))
.to.become(expectedResults);
});
});

0 comments on commit ed60fbe

Please sign in to comment.