From aa07b936776bc7f6f78a85f2741e396b668ed881 Mon Sep 17 00:00:00 2001 From: roggervalf Date: Sun, 17 Aug 2025 19:22:14 -0600 Subject: [PATCH 1/5] feat(preset): support ignoreCommits option --- index.js | 9 +++++++-- lib/load-changelog-config.js | 1 + test/integration.test.js | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index a3efe594..81372290 100644 --- a/index.js +++ b/index.js @@ -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 { commitsOpts, parserOpts, writerOpts } = await loadChangelogConfig(pluginConfig, context); const [match, auth, host, path] = /^(?!.+:\/\/)(?:(?.*)@)?(?.*?):(?.*)$/.exec(repositoryUrl) || []; let { hostname, port, pathname, protocol } = new URL( @@ -43,7 +43,7 @@ export async function generateNotes(pluginConfig, context) { const { issue, commit, referenceActions, issuePrefixes } = find(HOSTS_CONFIG, (conf) => conf.hostname === hostname) || HOSTS_CONFIG.default; - const parser = new CommitParser({ referenceActions, issuePrefixes, ...parserOpts }); + const parser = new CommitParser({ referenceActions, issuePrefixes, ...parserOpts}); const parsedCommits = filterRevertedCommitsSync( commits .filter(({ message, hash }) => { @@ -52,6 +52,11 @@ export async function generateNotes(pluginConfig, context) { return false; } + if(commitsOpts && commitsOpts.ignore && new RegExp(commitsOpts.ignore).test(message) && !commitsOpts.merges){ + debug("Skip commit %s by ignore option", hash); + return false; + } + return true; }) .map((rawCommit) => ({ diff --git a/lib/load-changelog-config.js b/lib/load-changelog-config.js index bbd69399..96f7bf59 100644 --- a/lib/load-changelog-config.js +++ b/lib/load-changelog-config.js @@ -33,6 +33,7 @@ export default async ({ preset, config, parserOpts, writerOpts, presetConfig }, } return { + commitsOpts: loadedConfig.commits, parserOpts: { ...loadedConfig.parser, ...parserOpts }, writerOpts: { ...loadedConfig.writer, ...writerOpts }, }; diff --git a/test/integration.test.js b/test/integration.test.js index 29c39822..83e65561 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -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 = [ From c4e376f22aeb42b285f7c64a95f210e66d419fa6 Mon Sep 17 00:00:00 2001 From: roggervalf Date: Sun, 17 Aug 2025 19:23:57 -0600 Subject: [PATCH 2/5] refactor: rename option --- index.js | 4 ++-- lib/load-changelog-config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 81372290..c5b329cc 100644 --- a/index.js +++ b/index.js @@ -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 { commitsOpts, parserOpts, writerOpts } = await loadChangelogConfig(pluginConfig, context); + const { commitOpts, parserOpts, writerOpts } = await loadChangelogConfig(pluginConfig, context); const [match, auth, host, path] = /^(?!.+:\/\/)(?:(?.*)@)?(?.*?):(?.*)$/.exec(repositoryUrl) || []; let { hostname, port, pathname, protocol } = new URL( @@ -52,7 +52,7 @@ export async function generateNotes(pluginConfig, context) { return false; } - if(commitsOpts && commitsOpts.ignore && new RegExp(commitsOpts.ignore).test(message) && !commitsOpts.merges){ + if(commitOpts && commitOpts.ignore && new RegExp(commitOpts.ignore).test(message) && !commitOpts.merges){ debug("Skip commit %s by ignore option", hash); return false; } diff --git a/lib/load-changelog-config.js b/lib/load-changelog-config.js index 96f7bf59..08be426e 100644 --- a/lib/load-changelog-config.js +++ b/lib/load-changelog-config.js @@ -33,7 +33,7 @@ export default async ({ preset, config, parserOpts, writerOpts, presetConfig }, } return { - commitsOpts: loadedConfig.commits, + commitOpts: loadedConfig.commits, parserOpts: { ...loadedConfig.parser, ...parserOpts }, writerOpts: { ...loadedConfig.writer, ...writerOpts }, }; From 2ae4988c226990ba9d24e56347afcaa2f1d52cb4 Mon Sep 17 00:00:00 2001 From: roggervalf Date: Fri, 22 Aug 2025 20:43:04 -0600 Subject: [PATCH 3/5] style: apply lint fixes --- index.js | 4 ++-- test/integration.test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index c5b329cc..cecb01dd 100644 --- a/index.js +++ b/index.js @@ -43,7 +43,7 @@ export async function generateNotes(pluginConfig, context) { const { issue, commit, referenceActions, issuePrefixes } = find(HOSTS_CONFIG, (conf) => conf.hostname === hostname) || HOSTS_CONFIG.default; - const parser = new CommitParser({ referenceActions, issuePrefixes, ...parserOpts}); + const parser = new CommitParser({ referenceActions, issuePrefixes, ...parserOpts }); const parsedCommits = filterRevertedCommitsSync( commits .filter(({ message, hash }) => { @@ -52,7 +52,7 @@ export async function generateNotes(pluginConfig, context) { return false; } - if(commitOpts && commitOpts.ignore && new RegExp(commitOpts.ignore).test(message) && !commitOpts.merges){ + if (commitOpts && commitOpts.ignore && new RegExp(commitOpts.ignore).test(message) && !commitOpts.merges) { debug("Skip commit %s by ignore option", hash); return false; } diff --git a/test/integration.test.js b/test/integration.test.js index 83e65561..ee360d7e 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -259,7 +259,7 @@ test.serial('Accept ignoreCommits in "presetConfig" object as option', async (t) { preset: "conventionalcommits", presetConfig: { - ignoreCommits: '\\[python\\]', + ignoreCommits: "\\[python\\]", types: [ { type: "fix", section: "Bug Fixes", hidden: false }, { type: "test", section: "Test !!", hidden: false }, From e16accf53aaa712f2d97219482cab51f200e905a Mon Sep 17 00:00:00 2001 From: roggervalf Date: Fri, 22 Aug 2025 20:59:15 -0600 Subject: [PATCH 4/5] docs(readme): add note about ignoreCommits option withing conventionalcommits --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0c62d2c5..e5600676 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,5 @@ With this example: **Note**: Individual properties of `parserOpts` and `writerOpts` will override ones loaded with an explicitly set `preset` or `config`. If `preset` or `config` are not set, only the properties set in `parserOpts` and `writerOpts` will be used. **Note**: For presets that expects a configuration object, such as [`conventionalcommits`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits), the `presetConfig` option **must** be set. + +**Note**: `ignoreCommits` is a supported option within `presetConfig` option when [`conventionalcommits`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits#specific-options) preset is used. From a655fbcf2e6ca3b8e5b762a5fce91d7c2b097489 Mon Sep 17 00:00:00 2001 From: Rogger Valverde Date: Fri, 29 Aug 2025 15:12:03 -0600 Subject: [PATCH 5/5] docs: remove specific note for conventionalcommit preset --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index e5600676..0c62d2c5 100644 --- a/README.md +++ b/README.md @@ -80,5 +80,3 @@ With this example: **Note**: Individual properties of `parserOpts` and `writerOpts` will override ones loaded with an explicitly set `preset` or `config`. If `preset` or `config` are not set, only the properties set in `parserOpts` and `writerOpts` will be used. **Note**: For presets that expects a configuration object, such as [`conventionalcommits`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits), the `presetConfig` option **must** be set. - -**Note**: `ignoreCommits` is a supported option within `presetConfig` option when [`conventionalcommits`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits#specific-options) preset is used.