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(raw-commits): allow hidding by subject pattern #1063

Merged

Conversation

roggervalf
Copy link
Contributor

@roggervalf roggervalf commented Jul 15, 2023

Add a way to hide commits with specific pattern from the release notes. This is useful in order to avoid commits with specific messages that we don't want to include in release notes

@dangreen dangreen self-requested a review July 15, 2023 10:06
@roggervalf
Copy link
Contributor Author

please @dangreen when you get a chance 👀

@dangreen
Copy link
Member

dangreen commented Aug 5, 2023

@roggervalf Hi. I think "types" is not right place for filtering by subject. We can add new option "ignore" to git-raw-commits to ignore commits by regex (here). And pass it option from preset

https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-conventionalcommits/index.js#L15

{
  gitRawCommitsOpts: {
    ignore: config.ignoreCommits,
    noMerges: null
  }
}

WDYT?

@roggervalf
Copy link
Contributor Author

@roggervalf Hi. I think "types" is not right place for filtering by subject. We can add new option "ignore" to git-raw-commits to ignore commits by regex (here). And pass it option from preset

https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-conventionalcommits/index.js#L15

{
  gitRawCommitsOpts: {
    ignore: config.ignoreCommits,
    noMerges: null
  }
}

WDYT?

Thank you @dangreen, sounds good to me, I think I could address it

@roggervalf roggervalf changed the title feat(writer-opts): allow hidding by subject pattern feat(raw-commits): allow hidding by subject pattern Aug 6, 2023
Copy link
Member

@dangreen dangreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore commit by pattern is a rare case, so I don't want to add new dependency for it. Regex should fit you needs

@@ -65,7 +65,9 @@ function gitRawCommits (rawGitOpts, rawExecOpts) {
transform (chunk, enc, cb) {
isError = false
setImmediate(() => {
readable.push(chunk)
if ( !(gitOpts?.ignore && isMatch(chunk.toString(), gitOpts?.ignore))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use regex instead of glob

const ignoreRegex = typeof gitOpts.ignore === 'string'
  ? new RegExp(gitOpts.ignore)
  : gitOpts.ignore
const shouldNotIgnore = ignoreRegex
  ? chunk => !ignoreRegex.test(chunk.toString())
  : () => true
...
if (shouldNotIgnore(chunk)) {
  readable.push(chunk)
}

@roggervalf
Copy link
Contributor Author

Thank you @dangreen, it sound good to me

@coveralls
Copy link

coveralls commented Aug 13, 2023

Coverage Status

coverage: 89.471% (-0.05%) from 89.525% when pulling c55c5e4 on roggervalf:feat-allow-hidding-by-subject into 7ec8a18 on conventional-changelog:master.

@dangreen dangreen merged commit 47033e6 into conventional-changelog:master Aug 13, 2023
6 checks passed
@roggervalf roggervalf deleted the feat-allow-hidding-by-subject branch August 13, 2023 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants