Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const debug = debugFactory("semantic-release:release-notes-generator");
export async function generateNotes(pluginConfig, context) {
const { commits, lastRelease, nextRelease, options, cwd } = context;
const repositoryUrl = options.repositoryUrl.replace(/\.git$/i, "");
const { parserOpts, writerOpts } = await loadChangelogConfig(pluginConfig, context);
const { commitOpts, parserOpts, writerOpts } = await loadChangelogConfig(pluginConfig, context);

const [match, auth, host, path] = /^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<path>.*)$/.exec(repositoryUrl) || [];
let { hostname, port, pathname, protocol } = new URL(
Expand All @@ -52,6 +52,11 @@ export async function generateNotes(pluginConfig, context) {
return false;
}

if (commitOpts && commitOpts.ignore && new RegExp(commitOpts.ignore).test(message) && !commitOpts.merges) {
debug("Skip commit %s by ignore option", hash);
return false;
}

return true;
})
.map((rawCommit) => ({
Expand Down
1 change: 1 addition & 0 deletions lib/load-changelog-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default async ({ preset, config, parserOpts, writerOpts, presetConfig },
}

return {
commitOpts: loadedConfig.commits,
parserOpts: { ...loadedConfig.parser, ...parserOpts },
writerOpts: { ...loadedConfig.writer, ...writerOpts },
};
Expand Down
26 changes: 26 additions & 0 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,32 @@ test.serial('Accept a partial "presetConfig" object as option', async (t) => {
t.regex(changelog, new RegExp(escape("* Change test ([222](https://github.com/owner/repo/commit/222))")));
});

test.serial('Accept ignoreCommits in "presetConfig" object as option', async (t) => {
const { generateNotes } = await import("../index.js");
const commits = [
{ hash: "111", message: "fix: First fix" },
{ hash: "222", message: "test: Change test [python]" },
];
const changelog = await generateNotes(
{
preset: "conventionalcommits",
presetConfig: {
ignoreCommits: "\\[python\\]",
types: [
{ type: "fix", section: "Bug Fixes", hidden: false },
{ type: "test", section: "Test !!", hidden: false },
],
},
},
{ cwd, options: { repositoryUrl }, lastRelease, nextRelease, commits }
);

t.regex(changelog, /### Bug Fixes/);
t.regex(changelog, new RegExp(escape("First fix")));
t.notRegex(changelog, /### Test !!/);
t.notRegex(changelog, new RegExp(escape("* Change test ([222](https://github.com/owner/repo/commit/222))")));
});

test.serial('Use "gitHead" from "lastRelease" and "nextRelease" if "gitTag" is not defined', async (t) => {
const { generateNotes } = await import("../index.js");
const commits = [
Expand Down