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

Incorrect parsing of the prepared commit message #173

Closed
axiac opened this issue Mar 4, 2022 · 2 comments · Fixed by #196
Closed

Incorrect parsing of the prepared commit message #173

axiac opened this issue Mar 4, 2022 · 2 comments · Fixed by #196

Comments

@axiac
Copy link

axiac commented Mar 4, 2022

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"
  }
@yiqianglin
Copy link

is there any solution?

@leonardoanalista
Copy link
Member

I created this PR @yiqianglin @axiac #196. Any thoughts?

leonardoanalista added a commit that referenced this issue Jul 2, 2022
leonardoanalista added a commit that referenced this issue Jul 2, 2022
jan-molak added a commit to serenity-js/serenity-js that referenced this issue Aug 25, 2022
…ggest, interrupting the flow

With the introduction of leoforfree/cz-customizable#122, cz-customizable pre-populates the
subject and the body of the commit message with whatever values the _previous_ commit message had.
When a commit message is long, this interrupts the developer workflow as a lengthy, non-editable
string of text derived from the previous commit takes up all the space for the _current_ commit and
confuses Inquirer CLI, which starts to render the cursor in an invalid location

Related tickets: re leoforfree/cz-customizable#173, re leoforfree/cz-customizable#196
jan-molak added a commit to serenity-js/serenity-js that referenced this issue Aug 25, 2022
…ggest, interrupting the flow

With the introduction of leoforfree/cz-customizable#122, cz-customizable pre-populates the
subject and the body of the commit message with whatever values the _previous_ commit message had.
When a commit message is long, this interrupts the developer workflow as a lengthy, non-editable
string of text derived from the previous commit takes up all the space for the _current_ commit and
confuses Inquirer CLI, which starts to render the cursor in an invalid location

Related tickets: re leoforfree/cz-customizable#173, re leoforfree/cz-customizable#196
leonardoanalista added a commit that referenced this issue Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants