Incorrect parsing of the prepared commit message
axiac opened this issue · 2 comments
The support for prepared commit message introduced in version 6.2.1 (PR #122) is broken. It does not take into account the format of the commit message, the same commit message that has been generated by this tool on the previous commit.
On the project I work on there is repository where several dozens of developers contribute with small changes. Most of the time they do not provide a long description to the commits because it is not needed. Everybody is used to just press <Enter>
on the question about the long description.
Let's see what happens in this case.
This is how the previous commit generated by this tool message looks like:
$ cat .git/COMMIT_EDITMSG
docs: blah-blah-blah
ISSUES CLOSED: #ABC-123
And this is the suggested answer on the question about the long description:
? Provide a LONGER description of the change (optional). Use "|" to break new line:
(ISSUES CLOSED: #ABC-123)
If I press <Enter>
as I am used to, the line ISSUES CLOSED: #ABC-123
becomes the long description of the commit. Another ISSUES CLOSED
line is added, of course, containing the Jira task ID that I provide on the question about the closed issues.
The content of .git/COMMIT_EDITMSG
becomes:
$ cat .git/COMMIT_EDITMSG
feat: a new feature
ISSUES CLOSED: #ABC-123
ISSUES CLOSED: #ABC-456
On the next yarn cz
, the suggested commit long description is:
? Provide a LONGER description of the change (optional). Use "|" to break new line:
(ISSUES CLOSED: #ABC-123|ISSUES CLOSED: #ABC-456)
And so on, and so forth. If I keep pressing <Enter>
to skip the long description, as my muscle memory has been trained in the last 4 years of using Commitizen, the ISSUES CLOSED
lines keeps piling up in my commit messages.
A possible solution for this issue is a configuration entry to enable/disable this functionality.
Commitizen and cz-configurable
are installed in the project as dev dependencies and cz-customizable
is used as a Commitizen plugin, configured in package.json
as described in the documentation:
"config": {
"commitizen": {
"path": "node_modules/cz-customizable"
},
"cz-customizable": {
"config": "commitizen.config.js"
}
},
Commitizen is executed using yarn cz
, a script defined in package.json
:
"scripts": {
"cz": "git cz"
}
is there any solution?
I created this PR @yiqianglin @axiac #196. Any thoughts?