diff --git a/lib/steps/changelog.js b/lib/steps/changelog.js index a723197..6054b0c 100644 --- a/lib/steps/changelog.js +++ b/lib/steps/changelog.js @@ -48,7 +48,7 @@ function addPullRequestCommits(pkg, commits, pr) { href: info.user.html_url, }; pr.href = info.html_url; - pr.title = info.title; + pr.title = info.title || info.header; var shas = pr.shas = _.map(prCommits, 'sha'); pr.commits = commits.filter(function isPartOfPR(commit) { return shas.indexOf(commit.sha) !== -1; @@ -134,9 +134,13 @@ function generateChangeLog(cwd, pkg, options) { } function formatCommit(commit) { - return getCommitLink(commit) + - ' **' + commit.type + ':** ' + - commit.subject + + var subject; + if (commit.type) { + subject = '**' + commit.type + ':** ' + commit.subject; + } else { + subject = commit.header; + } + return getCommitLink(commit) + ' ' + subject + formatReferences(commit.references); } diff --git a/test/steps/changelog.test.js b/test/steps/changelog.test.js index 9f40044..ab46537 100644 --- a/test/steps/changelog.test.js +++ b/test/steps/changelog.test.js @@ -289,8 +289,13 @@ describe('generateChangeLog', function () { pullId: '2', }, ]; + var sloppyCommits = commits.map(function (commit) { + if (commit.type === 'pr') return commit; + return { sha: commit.sha, header: commit.subject }; + }); var options = { commits: commits }; var changelog = null; + var sloppyChangelog = null; before('generateChangeLog', function () { return generateChangeLog(null, pkg, options) @@ -299,14 +304,26 @@ describe('generateChangeLog', function () { }); }); + before('generateSloppyChangeLog', function () { + return generateChangeLog(null, pkg, { commits: sloppyCommits }) + .then(function (_changelog) { + sloppyChangelog = _changelog; + }); + }); + it('calls out to github to get PR info', function () { - assert.equal(2, httpCalls.length); + assert.equal(4, httpCalls.length); }); it('ignores the PR', function () { assert.notInclude('* PR #2 Title', changelog); assert.include('* [`1234567`]', changelog); }); + + it('handles poorly formatted commit messages too', function () { + assert.include(') Stop doing the wrong thing\n', sloppyChangelog); + assert.include(') Do more things', sloppyChangelog); + }); }); describe('with a missing PR', function () {