Commitlint: footer-leading-blank complains about missing line

Created on 22 Feb 2018  Â·  3Comments  Â·  Source: conventional-changelog/commitlint

Expected Behavior

footer-leading-blank should pass if the footer has a leading blank line

Current Behavior

footer-leading-blank returns a warning if the footer has a leading blank line
and is present.

If no footer exists no warning is returned

Affected packages

  • [ ] cli
  • [ ] core
  • [ ] prompt
  • [ ] config-angular
  • [x] config-conventional

Possible Solution


Steps to Reproduce (for bugs)


  1. create a message like below
Author: Gregor Adams <[email protected]>
Date:   Thu Feb 22 16:32:55 2018 +0100

    docs(plugins): fix old docs

    Config -> Plugins

    closes #21


16:40 $ commitlint -e
â§—   input: docs(plugins): fix old docs
âš    footer must have leading blank line [footer-leading-blank]
âš    found 0 problems, 1 warnings


commitlint.config.js

{
  "extends": [
    "@commitlint/config-conventional"
  ]
}

Context


Your Environment

| Executable | Version |
| ---: | :--- |
| commitlint --version | 6.1.0 |
| git --version | 2.16.1 |
| node --version | v8.9.4 |

bug high

All 3 comments

This problem is also present in version 7.0.0. I had the warning with the following commit message:

    feat: mail is now created by the supplied template function

    Instead of supplying all mail fields in the queue the information from the queue is given to a
    template function. This helps to prevent creating open mail servers that can be abused for spam.
    Also refactored the tests to a more traditional style.

    BREAKING CHANGE: The `template` option is required.

When I look at the pasted commit message I see some leading spaces, but I guess that's just formatting. When I git commit --amend that commit it opens in nano without leading spaces.

I'm also running into this issue. It happens whenever I'm adding any breaking change or issue #.

  • Package: cz-customizable.
  • Commitlint Version: 7.0.0.

I freed up some time and started debugging this issue. Thanks for providing examples, these were very clear. Basically, the issue is related to the multi-newline between the header/subject and body.

None of the existing tests for footer-leading-blank contained multiple newlines between the body and feature. This means that a commit like test: something\nbody, is being transformed to array ["something", "body"].

Now, if we take the first example (docs(plugins): fix old docs\n\nConfig -> Plugins\n\ncloses #21) and convert it to array we get something like this. ["fix old docs", "", "Config -> Plugins", "", "closes #21"]. I don't think these empty strings are wrong, they still correctly represents a new line. But the way the footer-leading-blank extracts the footer doesn't work as expected in this example.

On this line you can see that the footer is being extracted using the body's length. But it does not take possible extra whitelines (or "body offset") into account, it simply adds 1 which again is not correct for this example.

I've written a fix, an I'm creating a PR now! 😄

You can see the full differences in this table, pay close attention to the starting line of the body for both.

line | without double line | with double line
--- | --- | ---
0 | something | fix old docs
1 | body |
2 | | Config -> Plugins
3 | |
4 | | closes #21

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ResDiaryLewis picture ResDiaryLewis  Â·  4Comments

juliuscc picture juliuscc  Â·  3Comments

gajus picture gajus  Â·  4Comments

topocount picture topocount  Â·  3Comments

texhnolyze picture texhnolyze  Â·  3Comments