Skip to content

Commit

Permalink
✨ Add filtering out referenced issues
Browse files Browse the repository at this point in the history
  • Loading branch information
priestine committed Jul 3, 2020
1 parent 51b288f commit 86212fb
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/pure/make-changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ const prettifyCommit = (convention: IConvention) => (commit: IRawCommit): string
.replace('%commit.hash%', commit.hash)
.replace('%commit.author.email%', commit.author.email)
.replace('%commit.author.name%', commit.author.name)
.concat(
commit.body
? '\n\n'.concat(
convention.itemBodyFormat.replace(
'%commit.body%',
commit.body.split(', ').filter(Boolean).join(', '),
),
)
: '',
)
.concat(prettifyCommitBody(commit.body, convention.itemBodyFormat))

const prettifyCommitBody = (commitBody: string, bodyFormat: string) => {
const cleanCommitBody = commitBody
.split(', ')
.filter(filterOutIssueReferences)
.filter(Boolean)
.join(', ')

return cleanCommitBody ? '\n\n'.concat(bodyFormat.replace('%commit.body%', cleanCommitBody)) : ''
}

const filterOutIssueReferences = (bodyLine: string) =>
!/clos(e|ed|es|ing)\s.*(#|http)/i.test(bodyLine) &&
!/resolv(e|ed|es|ing)\s.*(#|http)/i.test(bodyLine) &&
!/fix(e|ed|es|ing)\s.*(#|http)/i.test(bodyLine) &&
!/implement(ed|es|ing)\s.*(#|http)/i.test(bodyLine)

0 comments on commit 86212fb

Please sign in to comment.