Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added possibility to use regex to remove text from the commit message #610

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/macos,windows,linux,node
# End of https://www.gitignore.io/api/macos,windows,linux,node
/.vs
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ With this example:
| `commit` | Keyword used to generate commit links (formatted as `<host>/<owner>/<repository>/<commit>/<commit_sha>`). See [conventional-changelog-writer#commit](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#commit). | `commits` for Bitbucket repositories, `commit` otherwise |
| `issue` | Keyword used to generate issue links (formatted as `<host>/<owner>/<repository>/<issue>/<issue_number>`). See [conventional-changelog-writer#issue](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#issue). | `issue` for Bitbucket repositories, `issues` otherwise |
| `presetConfig` | Additional configuration passed to the [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset. Used for example with [conventional-changelog-conventionalcommits](https://github.com/conventional-changelog/conventional-changelog-config-spec/blob/master/versions/2.0.0/README.md). | - |
| `regexRemove` | Optional regular that will be used to clean up de message in the commit. For example to remove the Merged PR xxxx: part from a devops commit | - |

**Notes**: in order to use a `preset` it must be installed (for example to use the [eslint preset](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint) you must install it with `npm install conventional-changelog-eslint -D`)

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const debug = debugFactory("semantic-release:release-notes-generator");
* @param {String} pluginConfig.config Requireable npm package with a custom conventional-changelog preset
* @param {Object} pluginConfig.parserOpts Additional `conventional-changelog-parser` options that will overwrite ones loaded by `preset` or `config`.
* @param {Object} pluginConfig.writerOpts Additional `conventional-changelog-writer` options that will overwrite ones loaded by `preset` or `config`.
* @param {Object} context The semantic-release context.
* @param {Object} pluginConfig.regexRemove Optional regular that will be used to clean up de message in the commit. For example to remove the Merged PR xxxx: part from a devops commit* * @param {Object} context The semantic-release context.
* @param {Array<Object>} context.commits The commits to analyze.
* @param {Object} context.lastRelease The last release with `gitHead` corresponding to the commit hash used to make the last release and `gitTag` corresponding to the git tag associated with `gitHead`.
* @param {Object} context.nextRelease The next release with `gitHead` corresponding to the commit hash used to make the release, the release `version` and `gitTag` corresponding to the git tag associated with `gitHead`.
Expand Down Expand Up @@ -55,7 +55,7 @@ export async function generateNotes(pluginConfig, context) {
})
.map((rawCommit) => ({
...rawCommit,
...parser(rawCommit.message, { referenceActions, issuePrefixes, ...parserOpts }),
...parser(pluginConfig.regexRemove ? rawCommit.message.replace(new RegExp(pluginConfig.regexRemove), "") : rawCommit.message, { referenceActions, issuePrefixes, ...parserOpts }),
}))
);
const previousTag = lastRelease.gitTag || lastRelease.gitHead;
Expand Down
19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"name": "@semantic-release/release-notes-generator",
"description": "semantic-release plugin to generate changelog content with conventional-changelog",
"version": "0.0.0-development",
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
"name": "@tweeat/release-notes-generator",
"description": "tweeat plugin to generate changelog content with conventional-changelog",
"version": "1.0.0",
"type": "module",
"author": "Gert-Jan Naaktgeboren",
"bugs": {
"url": "https://github.com/semantic-release/release-notes-generator/issues"
"url": "https://github.com/Gert-Jan2AT/release-notes-generator/issues"
},
"contributors": [
"Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
"Gregor Martynus (https://twitter.com/gr2m)"
],
"dependencies": {
"conventional-changelog-angular": "^7.0.0",
"conventional-changelog-writer": "^7.0.0",
Expand Down Expand Up @@ -48,7 +45,7 @@
"wrappers",
"index.js"
],
"homepage": "https://github.com/semantic-release/release-notes-generator#readme",
"homepage": "https://github.com/Gert-Jan2AT/release-notes-generator#readme",
"keywords": [
"changelog",
"conventional-changelog",
Expand Down Expand Up @@ -86,7 +83,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/semantic-release/release-notes-generator.git"
"url": "https://github.com/Gert-Jan2AT/release-notes-generator.git"
},
"scripts": {
"lint": "prettier --check \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"{bin,lib,test}/*.js\"",
Expand Down