Skip to content

Commit d056cec

Browse files
nashifAnas Nashif
authored andcommitted
gitlint: Ignore signed-off-by line
When checking for line length limits, ignore lines with Signed-off-by. Some developers have a long name that would not fit within the limits. Signed-off-by: Anas Nashif <[email protected]>
1 parent b223f6a commit d056cec

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.gitlint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ words=wip,title
3535
# (e.g. title-must-not-contain-word).
3636
#regex=^US[0-9]*
3737

38-
[B1]
38+
[max-line-length-with-exceptions]
3939
# B1 = body-max-line-length
4040
line-length=72
4141

scripts/gitlint/zephyr_commit_rules.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from gitlint.rules import CommitRule, RuleViolation, TitleRegexMatches, CommitMessageTitle, LineRule
1+
from gitlint.rules import CommitRule, RuleViolation, TitleRegexMatches, CommitMessageTitle, LineRule, CommitMessageBody
22
from gitlint.options import IntOption, BoolOption, StrOption, ListOption
33
import re
44

@@ -68,3 +68,15 @@ def validate(self, title, _commit):
6868
violation_message = "Title does not follow <subsystem>: <subject>"
6969
if not pattern.search(title):
7070
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

Comments
 (0)