diff --git a/src/commits.js b/src/commits.js index 7d12849e..932c1487 100644 --- a/src/commits.js +++ b/src/commits.js @@ -80,6 +80,9 @@ function getTag (refs, options) { } function getSubject (message) { + if (!message) { + return '_No commit message_' + } return message.match(/[^\n]+/)[0] } diff --git a/test/commits.js b/test/commits.js index 58e97156..b4c42031 100644 --- a/test/commits.js +++ b/test/commits.js @@ -16,6 +16,7 @@ import { const parseCommits = __get__('parseCommits') const getFixes = __get__('getFixes') const getMerge = __get__('getMerge') +const getSubject = __get__('getSubject') const options = { tagPrefix: '' @@ -234,3 +235,13 @@ describe('getMerge', () => { }) }) }) + +describe('getSubject', () => { + it('returns commit subject', () => { + const message = 'Commit message\n\nCloses ABC-1234' + expect(getSubject(message)).to.equal('Commit message') + }) + it('returns no commit message', () => { + expect(getSubject('')).to.equal('_No commit message_') + }) +})