gitlint: ignore titles prefixed with Revert
The revert commit title is usually prefixed with "Revert" which causes
the title to become longer than the allowed limit. Allow such commits to
keep revert commits consistent with the original commit message.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
diff --git a/scripts/gitlint/zephyr_commit_rules.py b/scripts/gitlint/zephyr_commit_rules.py
index e4664a8..dfeb35e 100644
--- a/scripts/gitlint/zephyr_commit_rules.py
+++ b/scripts/gitlint/zephyr_commit_rules.py
@@ -55,6 +55,17 @@
return
return [RuleViolation(self.id, "Body does not contain a 'Signed-Off-By' line", line_nr=1)]
+class TitleMaxLengthRevert(LineRule):
+ name = "title-max-length-no-revert"
+ id = "UC5"
+ target = CommitMessageTitle
+ options_spec = [IntOption('line-length', 72, "Max line length")]
+ violation_message = "Title exceeds max length ({0}>{1})"
+
+ def validate(self, line, _commit):
+ max_length = self.options['line-length'].value
+ if len(line) > max_length and not line.startswith("Revert"):
+ return [RuleViolation(self.id, self.violation_message.format(len(line), max_length), line)]
class TitleStartsWithSubsystem(LineRule):
name = "title-starts-with-subsystem"