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

Print commit message after error message if it is invalid #222

Closed
2 of 4 tasks
dnamorim opened this issue Jan 9, 2018 · 6 comments · Fixed by #302
Closed
2 of 4 tasks

Print commit message after error message if it is invalid #222

dnamorim opened this issue Jan 9, 2018 · 6 comments · Fixed by #302

Comments

@dnamorim
Copy link
Contributor

dnamorim commented Jan 9, 2018

Currently, when using the CLI, if the message is invalid we lose all its content (using a custom message in VIM mode), which might be a little frustrating when we a have a long commit body, so it would be nice if we show the previous message after the linting errors.

Expected Behavior

If the message fails it could be printed to after the error message like:

⧗   input:
foo

Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum iure distinctio atque dolorum 
ratione? Ullam, impedit nemo. Porro, quasi. Tempore rem facere ut enim dolores consequuntur illo 
maiores consequatur provident.

✖   type may not be empty [type-empty]
✖   found 1 problems, 0 warnings

Current Behavior

Currently, it only shows the following output:

⧗   input: foo
✖   type may not be empty [type-empty]
✖   found 1 problems, 0 warnings

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

This can be done in the @commitlint/cli/src/cli.js module by not splitting the message by \n in case of error so we have access to the whole message to further edit.

Steps to Reproduce (for bugs)

  1. Create a config file as described below.
  2. Create a commit message with a body like:
 foo

 Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum iure distinctio atque dolorum 
 ratione? Ullam, impedit nemo. Porro, quasi. Tempore rem facere ut enim dolores consequuntur illo 
 maiores consequatur provident.
  1. The message will be invalid and the input only refers to the commit title.
commitlint.config.js
module.exports = {
  rules: {
    'type-empty': [2, 'never']
  }
};

Context

In our workflow, the commit messages are as much detailed as possible since their contents are used to create the PR description. If the message is very long it is quite frustrating if something is invalid and we lose all the previous work.

Your Environment

Executable Version
commitlint --version 5.2.8
git --version 2.14.3
node --version 8.9.3
@marionebl
Copy link
Contributor

I think this is a good idea, any chance you could help out with this?

@dnamorim
Copy link
Contributor Author

@marionebl Sure. I'll try to open a PR with this enhancement in the next days.

@marionebl
Copy link
Contributor

@dnamorim Are you still interested in this?

@dnamorim
Copy link
Contributor Author

dnamorim commented Feb 3, 2018

@marionebl Yes. I'm sorry but I didn't have the time to fully finish this. I'll try to open a PR this weekend.

@marionebl
Copy link
Contributor

No worries, just asking to know if I should take this up. Any help is greatly appreciated. 👍

dnamorim pushed a commit to dnamorim/commitlint that referenced this issue Feb 26, 2018
When using the CLI, if the message is invalid we lose all its content (using a custom message in VIM mode), which might be a little frustrating when we a have a long commit body.

This feature prints the full message when there are linting errors.

Closes conventional-changelog#222
dnamorim pushed a commit to dnamorim/commitlint that referenced this issue Mar 5, 2018
When using the CLI, if the message is invalid we lose all its content (using a custom message in VIM mode), which might be a little frustrating when we a have a long commit body.

This feature prints the full message when there are linting errors.

Closes conventional-changelog#222
dnamorim pushed a commit to dnamorim/commitlint that referenced this issue Mar 5, 2018
When using the CLI, if the message is invalid we lose all its content (using a custom message in VIM mode), which might be a little frustrating when we a have a long commit body.

This feature prints the full message when there are linting errors.

Closes conventional-changelog#222
marionebl pushed a commit that referenced this issue Mar 19, 2018
When using the CLI, if the message is invalid we lose all its content (using a custom message in VIM mode), which might be a little frustrating when we a have a long commit body.

This feature prints the full message when there are linting errors.

Closes #222
@ZauberNerd
Copy link

Another option would be to run git commit --file=.git/COMMIT_EDITMSG --edit after a failed validation to reopen the message in ./git/COMMIT_EDITMSG in your editor.

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

Successfully merging a pull request may close this issue.

3 participants