Skip to content

Commit

Permalink
Apply ignoreCommitPattern earlier in the parsing logic
Browse files Browse the repository at this point in the history
Fixes #195
Sort of fixes #187 too
  • Loading branch information
cookpete committed May 21, 2021
1 parent 44e8085 commit d27152d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const parseCommits = (string, options = {}) => {
.split(COMMIT_SEPARATOR)
.slice(1)
.map(commit => parseCommit(commit, options))
.filter(commit => filterCommit(commit, options))
}

const parseCommit = (commit, options = {}) => {
Expand Down Expand Up @@ -133,6 +134,13 @@ const getMerge = (commit, message, options = {}) => {
return null
}

const filterCommit = (commit, { ignoreCommitPattern }) => {
if (ignoreCommitPattern && new RegExp(ignoreCommitPattern).test(commit.subject)) {
return false
}
return true
}

module.exports = {
COMMIT_SEPARATOR,
MESSAGE_SEPARATOR,
Expand Down
7 changes: 2 additions & 5 deletions src/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const parseReleases = async (tags, options, onParsed) => {
const { message } = commits[0] || { message: null }
const breakingCount = commits.filter(c => c.breaking).length
const filteredCommits = commits
.filter(filterCommits(options, merges))
.filter(filterCommits(merges))
.sort(sortCommits(options))
.slice(0, getCommitLimit(options, emptyRelease, breakingCount))

Expand All @@ -29,17 +29,14 @@ const parseReleases = async (tags, options, onParsed) => {
}))
}

const filterCommits = ({ ignoreCommitPattern }, merges) => commit => {
const filterCommits = merges => commit => {
if (commit.fixes || commit.merge) {
// Filter out commits that already appear in fix or merge lists
return false
}
if (commit.breaking) {
return true
}
if (ignoreCommitPattern && new RegExp(ignoreCommitPattern).test(commit.subject)) {
return false
}
if (semver.valid(commit.subject)) {
// Filter out version commits
return false
Expand Down

0 comments on commit d27152d

Please sign in to comment.