Skip to content

Commit

Permalink
fix: filter out commits with empty message
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Nov 27, 2019
1 parent 99e861e commit 763f0b2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
17 changes: 13 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,19 @@ async function generateNotes(pluginConfig, context) {
const {issue, commit, referenceActions, issuePrefixes} =
find(HOSTS_CONFIG, conf => conf.hostname === hostname) || HOSTS_CONFIG.default;
const parsedCommits = filter(
commits.map(rawCommit => ({
...rawCommit,
...parser(rawCommit.message, {referenceActions, issuePrefixes, ...parserOpts}),
}))
commits
.filter(({message, hash}) => {
if (!message.trim()) {
debug('Skip commit %s with empty message', hash);
return false;
}

return true;
})
.map(rawCommit => ({
...rawCommit,
...parser(rawCommit.message, {referenceActions, issuePrefixes, ...parserOpts}),
}))
);
const previousTag = lastRelease.gitTag || lastRelease.gitHead;
const currentTag = nextRelease.gitTag || nextRelease.gitHead;
Expand Down
15 changes: 15 additions & 0 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,21 @@ test('Exclude commits if they have a matching revert commits', async t => {
t.notRegex(changelog, /Second feature/);
});

test('Exclude commits with empty message', async t => {
const commits = [
{hash: '111', message: 'fix(scope1): First fix'},
{hash: '222', message: ''},
{hash: '333', message: ' '},
];
const changelog = await generateNotes({}, {cwd, options: {repositoryUrl}, lastRelease, nextRelease, commits});

t.regex(changelog, new RegExp(escape('(https://github.com/owner/repo/compare/v1.0.0...v2.0.0)')));
t.regex(changelog, /### Bug Fixes/);
t.regex(changelog, new RegExp(escape('* **scope1:** First fix ([111](https://github.com/owner/repo/commit/111))')));
t.notRegex(changelog, /222/);
t.notRegex(changelog, /333/);
});

test('Throw error if "preset" doesn`t exist', async t => {
const commits = [
{hash: '111', message: 'Fix: First fix (fixes #123)'},
Expand Down

0 comments on commit 763f0b2

Please sign in to comment.