Skip to content

Commit

Permalink
fix: 拼接 body & footer 在多个 type 的情况下
Browse files Browse the repository at this point in the history
  • Loading branch information
imcuttle committed Oct 18, 2018
1 parent 0260965 commit d42d892
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ betterThanBefore.setups([
function() {
shell.exec('git tag v1.0.2')
// gitDummyCommit(['fix: lalal & fix: asas & feat: lalala'])
gitDummyCommit(['fix: lalal \nfix: asas @yucong02 \nfeat: lalala', 'chore: ssss'])
gitDummyCommit(['fix: lalala \nfix: asas @yucong02 \nfeat: lalala', 'closed #123, #222'])
gitDummyCommit(['fix: lalal \n illegal'])
},
// 13
function() {
shell.exec('git tag v1.0.3')
gitDummyCommit(['fix: nihao @yucong02 & sdsd & fix: 你好nihao & sdsd & feat: 看看看& & asd'])
gitDummyCommit([
'fix: nihao @yucong02 & sdsd & fix: 你好nihao & sdsd & feat: 看看看& & asd',
'feat: newline',
'closed #123, #233'
])
gitDummyCommit(['fix: lalal \n newline-illegal'])
gitDummyCommit(['fix: lalal & illegal'])
gitDummyCommit(['lalal & illegal'])
Expand Down Expand Up @@ -528,7 +532,7 @@ describe('befe preset', function() {
through(function(chunk) {
chunk = chunk.toString()
console.log(chunk)
expect(chunk).to.match(/### \n\n\* asas \[@yucong02].+?\n\* lalal .+?\n\* lalal .+?\n/)
expect(chunk).to.match(/### \n\n\* asas \[@yucong02].+?\n\* lalal .+?\n\* lalala .+, \[#123]/)
expect(chunk).to.match(/### \n\n\* lalala .+?\s+$/)
done()
})
Expand All @@ -548,9 +552,9 @@ describe('befe preset', function() {
chunk = chunk.toString()
console.log(chunk)
expect(chunk).to.match(
/### \n\n\* lalal .+?\n\* lalal & illegal .+?\n\* nihao \[@yucong02].+? & sdsd .+?\n\* nihao & sdsd /
/### \n\n\* lalal .+?\n\* lalal & illegal .+?\n\* nihao \[@yucong02].+ & sdsd .+\n.*\* nihao & sdsd/
)
expect(chunk).to.match(/### \n\n\* * & & asd .+?\s+/)
expect(chunk).to.match(/### [^]*newline.*\n[^]*& & asd/)
done()
})
)
Expand Down
3 changes: 2 additions & 1 deletion writer-opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ function getWriterOpts() {
let hasTypeInHeader = false

const pushCommit = line => {
if (!line) return false
const obj = sync(line, parserOpts)
if (!obj.type) return false
const newCommit = Object.assign({}, commit, obj)
Expand Down Expand Up @@ -270,7 +271,7 @@ function getWriterOpts() {

if (rest) {
if (isFirst) {
pushCommit(slicedMsg)
pushCommit([slicedMsg, commit.body, commit.footer].join('\n\n'))
isFirst = false
}
hasTypeInHeader = true
Expand Down

0 comments on commit d42d892

Please sign in to comment.