Skip to content

Commit

Permalink
Support commits with no message
Browse files Browse the repository at this point in the history
Fixes #27
  • Loading branch information
cookpete committed Jan 30, 2018
1 parent d516a91 commit d0470fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ function getTag (refs, options) {
}

function getSubject (message) {
if (!message) {
return '_No commit message_'
}
return message.match(/[^\n]+/)[0]
}

Expand Down
11 changes: 11 additions & 0 deletions test/commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
const parseCommits = __get__('parseCommits')
const getFixes = __get__('getFixes')
const getMerge = __get__('getMerge')
const getSubject = __get__('getSubject')

const options = {
tagPrefix: ''
Expand Down Expand Up @@ -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_')
})
})

0 comments on commit d0470fb

Please sign in to comment.