admin管理员组

文章数量:1391995

gitlint is a handy tool and for example useful to limit the max line length of commit messages to 72 characters - as widely adopted standard across many projects. However, this rule also doesn't allow me to insert long links anymore. What can I do to have the best of both worlds?

gitlint is a handy tool and for example useful to limit the max line length of commit messages to 72 characters - as widely adopted standard across many projects. However, this rule also doesn't allow me to insert long links anymore. What can I do to have the best of both worlds?

Share Improve this question edited Mar 13 at 6:25 phip1611 asked Mar 12 at 10:26 phip1611phip1611 6,2305 gold badges41 silver badges75 bronze badges 2
  • "limit commit messages to a length of 72 characters" - surely you mean the commit message title? – 1615903 Commented Mar 13 at 5:53
  • 1 YIKES, thanks. I adapted the question. I was talking about the max line length – phip1611 Commented Mar 13 at 6:26
Add a comment  | 

1 Answer 1

Reset to default 0

An easy solution is to use the ignore-body-lines configuration property. We can use a regex for each line starting with the pattern http[s]://. We then can ignore the body-max-line-length rule for that given case.

[body-max-line-length]
line-length=72

# Don't annoy users when they add long links to useful resources
[ignore-by-body]
regex=^https?:\/\/
ignore=body-max-line-length

Now your commit message can look like this:

fix: security vulnerability in xyz

The bug [0] is now solved using the solution presented in [1].


[0]
http://very-very-very-very-very-very-very-very-very-very-very-very-very.long.link
[1]
https://very-very-very-very-very-very-very-very-very-very-very-very-very.long.link

本文标签: gitConfigure gitlint to ignore long links when they exceed the maximum line lengthStack Overflow