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

fix: Revert in the beginning of commit message ignores all rules #3691

Closed
2 of 4 tasks
arxeiss opened this issue Oct 10, 2023 · 5 comments
Closed
2 of 4 tasks

fix: Revert in the beginning of commit message ignores all rules #3691

arxeiss opened this issue Oct 10, 2023 · 5 comments

Comments

@arxeiss
Copy link
Contributor

arxeiss commented Oct 10, 2023

Expected Behavior

When message starts with Revert keyword, I would expect the rules are evaluated too. But all rules are now completely ignored.

Current Behavior

If there is Revert, no check is performed at all.

$ echo "Revert bla bla bla" | commitlint -V
    ⧗   input: Revert bla bla bla
    ✔   found 0 problems, 0 warnings

But without Revert, everything goes well

$ echo "bla bla bla" | commitlint -V 
    ⧗   input: bla bla bla
    ✖   subject may not be empty [subject-empty]
    ✖   type may not be empty [type-empty]
    ⚠   Your commit message is missing JIRA ticket. Consider adding it to commit body or ignore this error. [contains-jira-ticket]
    
    ✖   found 2 problems, 1 warnings

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

No response

Steps to Reproduce

1. Create `commitlint.config.js` with content below
2. Execute `echo "Revert bla bla bla" | commitlint -V` and `echo "bla bla bla" | commitlint -V` to see different behavior. 


module.exports = {
  extends: ["@commitlint/config-conventional"]
}

Context

We use Release please action to trigger releases when specific subject is in the message. And when message is like Revert "feat: xxx" it is not triggering release.

Plus we have some limitations in our pipeline, that specific characters cannot be in commit message. Like " or ' or `.
So we have custom rule, but that one is never applied, if there is Revert in the beginning of the message.

commitlint --version

@commitlint/cli@17.7.2

git --version

git version 2.42.0

node --version

v18.13.0

@arxeiss arxeiss added the bug label Oct 10, 2023
@escapedcat
Copy link
Member

Looks like this works as intended.
You should be able to disable defaults and set your own in the config.

@escapedcat escapedcat removed the bug label Oct 10, 2023
@arxeiss
Copy link
Contributor Author

arxeiss commented Oct 10, 2023

You are right. I was searching through the doc for option like this but missed it. Plus I was a bit confused by

  /*
   * Functions that return true if commitlint should ignore the given message.
   */
  ignores: [(commit) => commit === ''],

So it seems like it ignores only empty string. And commitlint --print-config shows

ignores: undefined,
defaultIgnores: undefined,

Would it be possible to add link to https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/is-ignored/src/defaults.ts#L17 into documentation or document the ignored regexes somewhere? What do you think?

@escapedcat
Copy link
Member

Sure, happy for any PRs improving the docs!

@arxeiss
Copy link
Contributor Author

arxeiss commented Oct 10, 2023

PR is here: #3692
But for some reason, checks are not starting.

@escapedcat
Copy link
Member

Checks need to be approved. Just did that. Thanks! Will merge. Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants