Skip to content

{body,footer}-max-line-length may fail when git commit --verbose #437

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

Open
2 tasks done
Fetz opened this issue Sep 9, 2018 · 3 comments
Open
2 tasks done

{body,footer}-max-line-length may fail when git commit --verbose #437

Fetz opened this issue Sep 9, 2018 · 3 comments

Comments

@Fetz
Copy link
Contributor

Fetz commented Sep 9, 2018

Expected Behavior

{body,footer}-max-line-length should only validate the body of the message and the footer of the message

Current Behavior

if the git commit is done with the verbose option (that will show the diff), the rules {body,footer}-max-line-length will run even on the diff

Affected packages

  • ensure
  • rules

Possible Solution

maybe commitlint should have a pre processing step and remove content before the diff

Maybe split by:

const newValue = value.split("diff --git a/")[0];

Steps to Reproduce (for bugs)

  1. With the code from https://github.com/marionebl/commitlint/pull/436
  2. Make a change that causes a line to be bigger than 100
  3. git add that change
  4. git commit to open the default editor with the diff (if doesn't show the diff do git commit --verbose
  5. write a valid commit message
  6. will fail

Context

Found out when trying to commit this changes: https://github.com/marionebl/commitlint/pull/436
When doing a commit message with: git commit -m "<message>" it was working
But when I was commit like: git commit typing the message in editor and save, it was failling

Your Environment

editor: neovim

Executable Version
commitlint --version latest
git --version 2.18.0
node --version v8.11.3
@marionebl
Copy link
Contributor

Generally I avoid parsing the commit message in commitlint as that work is delegated to conventional-commits-parser.

Filtering out diff lines prob. should be added there, so the entire ecosystem can benefit. What do you think?

@Fetz
Copy link
Contributor Author

Fetz commented Sep 11, 2018

Yes I agree, I will create a ticket there and link to this one, so if they agree that should be fixed me or someone will try to fix this issue so we can unblock my other PR

@robsonpeixoto
Copy link

Any hack/tip of how to avoid this body-max-line-length error?

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

No branches or pull requests

4 participants