From 5ad5fac4d55d6c0146e9be2d49ab9ca4c5a186f0 Mon Sep 17 00:00:00 2001 From: Vebjorn Myklebust Date: Wed, 21 Oct 2026 18:38:00 +0200 Subject: [PATCH] TI: gitlint: exclude patch tags from title max length Downstream commits prefix the title with a patch tag such as UPSTREAM-PEND:, UPSTREAM:, PEND:, TI:, or TI: HACK: Strip the leading tag before checking the title length, so that the 75 character limit only applies to the actual title. Signed-off-by: Vebjorn Myklebust --- scripts/gitlint/zephyr_commit_rules.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/gitlint/zephyr_commit_rules.py b/scripts/gitlint/zephyr_commit_rules.py index a2c9cd3cb7fe..1868fb953227 100644 --- a/scripts/gitlint/zephyr_commit_rules.py +++ b/scripts/gitlint/zephyr_commit_rules.py @@ -81,10 +81,14 @@ class TitleMaxLengthRevert(LineRule): options_spec = [IntOption('line-length', 75, "Max line length")] violation_message = "Commit title exceeds max length ({0}>{1})" + # Downstream patch tags (e.g. "UPSTREAM-PEND: ") don't count towards the max length + patch_tag_regex = re.compile(r"^(?:UPSTREAM-PEND|UPSTREAM|PEND|TI: HACK|TI): ") + 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)] + title = self.patch_tag_regex.sub("", line, count=1) + if len(title) > max_length and not title.startswith("Revert"): + return [RuleViolation(self.id, self.violation_message.format(len(title), max_length), line)] class TitleStartsWithSubsystem(LineRule): name = "title-starts-with-subsystem"