|
1 |
| -from gitlint.rules import CommitRule, RuleViolation, TitleRegexMatches, CommitMessageTitle, LineRule |
| 1 | +from gitlint.rules import CommitRule, RuleViolation, TitleRegexMatches, CommitMessageTitle, LineRule, CommitMessageBody |
2 | 2 | from gitlint.options import IntOption, BoolOption, StrOption, ListOption
|
3 | 3 | import re
|
4 | 4 |
|
@@ -68,3 +68,15 @@ def validate(self, title, _commit):
|
68 | 68 | violation_message = "Title does not follow <subsystem>: <subject>"
|
69 | 69 | if not pattern.search(title):
|
70 | 70 | return [RuleViolation(self.id, violation_message, title)]
|
| 71 | + |
| 72 | +class MaxLineLengthExceptions(LineRule): |
| 73 | + name = "max-line-length-with-exceptions" |
| 74 | + id = "UC4" |
| 75 | + target = CommitMessageBody |
| 76 | + options_spec = [IntOption('line-length', 80, "Max line length")] |
| 77 | + violation_message = "Line exceeds max length ({0}>{1})" |
| 78 | + |
| 79 | + def validate(self, line, _commit): |
| 80 | + max_length = self.options['line-length'].value |
| 81 | + if len(line) > max_length and not line.startswith('Signed-off-by'): |
| 82 | + return [RuleViolation(self.id, self.violation_message.format(len(line), max_length), line)] |
0 commit comments