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

RFE: support for ignoring lines matching a regexp #369

Open
scop opened this issue Feb 4, 2024 · 1 comment
Open

RFE: support for ignoring lines matching a regexp #369

scop opened this issue Feb 4, 2024 · 1 comment

Comments

@scop
Copy link
Contributor

scop commented Feb 4, 2024

Caveat: haven't actually used committed much at all yet, reporting/requesting this based on docs reference.

The line_length option seems to be nice in the sense that it ignores long lines that don't contain a "break" (although I don't know what exactly that means, I hope it's just whitespace) to avoid breaking URLs and the like.

However, it would be nice to be able to ignore certain other lines even if they do contain whitespace. I've used this config with gitlint previously:

[ignore-body-lines]
regex = ^(Co-authored-by:|((Closes|Refs|See|-|\*):? )?https?://)

... to not demand splitting e.g. the following over multiple lines / not complain about the line length. Some of these would break functionality if split over multiple lines, for others it would just feel awkward.

Co-authored-by: long-long-email-address@example.com
Closes: https://example.com/long-long-url
See https://example.com/long-long-url
- https://example.com/long-long-url-in-a-bulleted-list-in-commit-message
* https://example.com/long-long-url-in-another-type-of-bulleted-list-in-commit-message
@epage
Copy link
Collaborator

epage commented Feb 5, 2024

I'm fine adding something like this if there is a need.

iirc our check only complains if a space exists after line_length, so I don't think it'd fire in those cases (the spaces are before line_length)

let line = line.trim_end();
let last_space_index = line.rfind(' ').unwrap_or(0);
let soft_line = &line[0..last_space_index];
let count = unicode_segmentation::UnicodeSegmentation::graphemes(soft_line, true).count();
if max_length < count {

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

No branches or pull requests

2 participants