conventional-changelog / commitlint

πŸ““ Lint commit messages
https://commitlint.js.org
MIT License
16.29k stars 882 forks source link

feature: add flag to enable/disable multiple-scopes (default: enabled) #4015

Open wlc015f opened 2 months ago

wlc015f commented 2 months ago

Expected Behavior

our projects previous use scope like: feat(A/B): commit msg, B is a sub scope of A.

when we update @commitlint/cli from 8.3.5 to 19.2.1 , it doesn't work well as before, because for version 19.2.1 "/" is scopes delimiter to divide input scope string into several scopes.

Current Behavior

scopeEnum would divide input scope "A/B" to scope "A" and "B" to check if input scope in commitlint config rules scope-enum, we previous config scope "A/B" can not pass isScopeInEnum check.

Steps to reproduce

  1. nodejs project with @commitlint/cli 19.2.1 and husky 9.0.11
  2. set husky hooks commit-msg npx --no -- commitlint --edit $1
  3. project commitlint.config.js is
    module.exports = {
    extends: [...],
    rules: {
        "scope-empty": [2, "never"],
        "scope-enum": [2, "always", ["workload/record"]]
    }
    }
  4. make some changes and commit code with message test(workload/record): test commit , then get error message below:
    
    % git commit -m "test(workload/record): test commit" 
    πŸ”  Finding changed files since git revision af2ddf4d.
    🎯  Found 1 changed file.
    βœ…  Everything is awesome!
    β§—   input: test(workload/record): test commit
    βœ–   scope must be one of [workload, workload/record,...] 

βœ– found 1 problems, 0 warnings β“˜ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

husky - commit-msg script failed (code 1)



### Affected packages

- [ ] cli
- [X] core
- [ ] prompt
- [ ] config-angular

### Possible Solution

set scopes delimiter as a optional config for user may solve this problem, if user do not config scopes delimiter, it will works well as before.

### Context

https://github.com/conventional-changelog/commitlint/issues/701#issuecomment-2044065538
escapedcat commented 2 months ago

Which version did you use before? Can you show some terminal output to make your issue more understandable. And update the title to describe your issue better. Thanks!

escapedcat commented 2 months ago

Thanks for clarifying your issue!

The update from 8.3.5 to 19.2.1 has several breaking issues.

901 was added in v9 and might cause your issue.

Looking at it now it would have been good to add a flag to enable/disable on multiple scopes. Might have even been a breaking change I guess but we didn't notice.

Maybe adding such flag would help in your situation?

wlc015f commented 2 months ago

Thanks for clarifying your issue!

The update from 8.3.5 to 19.2.1 has several breaking issues. #901 was added in v9 and might cause your issue.

Looking at it now it would have been good to add a flag to enable/disable on multiple scopes. Might have even been a breaking change I guess but we didn't notice.

Maybe adding such flag would help in your situation?

yeah, a switch flag will solve my situation.

escapedcat commented 2 months ago

Would you be able to create a PR?

wlc015f commented 2 months ago

Would you be able to create a PR?

I'd like to try

knocte commented 2 months ago

@wlc015f I still don't grasp the issue here because you missed the "Steps to reproduce" part, can you at least attach the commitlint configuration you were using?

wlc015f commented 2 months ago

@wlc015f I still don't grasp the issue here because you missed the "Steps to reproduce" part, can you at least attach the commitlint configuration you were using?

add the details above

wlc015f commented 2 months ago

to Implement the feature, I have looked over the relevant code, and prefer to place the code related to parse message scopes with config under the @commitlint/parse module or into the conventional-commits-parser package, function scopeEnum should just validate the rules with input config with parsed data. i need some advice/guidance @escapedcat @knocte

knocte commented 2 months ago

under the @commitlint/parse module or into the conventional-commits-parser package

Yeah, I guess you should aim at creating a PR here: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser

to Implement the feature,

BTW, if I understood this ticket correctly, this is a bug, not a feature.

escapedcat commented 2 months ago

Yes, I guess it was a breaking change because multiple scopes were added "enabled by default", right? But it's done already... so I guess this "feature" is the best option?

wlc015f commented 2 months ago

BTW, if I understood this ticket correctly, this is a bug, not a feature.

Yes, I guess it was a breaking change because multiple scopes were added "enabled by default", right? But it's done already... so I guess this "feature" is the best option?

I think it should be worked on as a feature.

escapedcat commented 2 months ago

Would you be able to create a PR?

wlc015f commented 2 months ago

Would you be able to create a PR?

I'd like to try this weekend