cz-cli
cz-cli copied to clipboard
support breaking changes without a longer description
Currently if I try to create a commit with breaking changes but without a longer description I get the following message: "A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself:". According to the examples from the Conventional Commits spec commit messages where the body consists of only a breaking change are valid and should be supported by Commitizen.
Currently, the conventional commits specs require a description in the footer OR you must end your commit type with a "!" (https://www.conventionalcommits.org/en/v1.0.0/#commit-message-with-to-draw-attention-to-breaking-change).
Can you provide an example that I can try to recreate? (Adaptor used, configuration, etc.). Thanks!
what OP is referring to is an extra prompt in addition to the one that inserts the "BREAKING CHANGE: " section in the commit body. i usually leave that prompt blank since i would have added the longer description myself if i wanted it to be included. problem is that the extra prompt only shows up if you didnt already populate the longer description, so i often add my breaking change description there instead of the proper prompt that follows and end up having to restart
Here's an example:
npx cz
[email protected], [email protected]
? Select the type of change that you're committing: feat: A new feature
? What is the scope of this change (e.g. component or file name): (press enter to skip)
? Write a short, imperative tense description of the change (max 94 chars):
(17) short description
? Provide a longer description of the change: (press enter to skip)
? Are there any breaking changes? Yes
? A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself:
long description
? Describe the breaking changes:
breaking change description
? Does this change affect any open issues? No
And here's the resulting commit message:
feat: short description
BREAKING CHANGE: breaking change description
As you can see commitizen re-prompted for a commit body after I responded "Yes" to "Are there any breaking changes?" even though I skipped the earlier "Provide a longer description of the change" prompt. Now it did omit that longer description in the actual commit message as I would expect but the prompt is still unnecessary and could be misleading for newcomers to a project that uses commitizen.
Ah, I see now. I know it's not the best solution but if you are using cz-customizable you can set the configuration to have askForBreakingChangeFirst: true as a workaround.
I agree that this isn't the best solution, especially if you're using another adaptor... 🤔 I'd like to implement the fix here, but I'd be concerned about breaking adaptors that may not use the breakingChange question - I'm still fairly new to the project so I'll have to take a look at the internals when I have some time.
For the meanwhile, I'm adding the tag for "needs PR" and "bug" for now to mark this as "triaged" for the moment. I know this isn't ideal, but the Issues and PR lists are really long for the size of the projects and I'm working on pairing them down at the moment.
Ok no problem. The project I work on hasn't adopted commitizen-cli yet but I am planning to add it eventually.