Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions scripts/gitlint/zephyr_commit_rules.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: Apache-2.0

Check warning on line 1 in scripts/gitlint/zephyr_commit_rules.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Copyright missing

scripts/gitlint/zephyr_commit_rules.py:1 File has no SPDX-FileCopyrightText header, consider adding one. Check SPDX headers and copyright lines with the reuse Python API.

"""
The classes below are examples of user-defined CommitRules. Commit rules are gitlint rules that
Expand Down Expand Up @@ -81,10 +81,14 @@
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"
Expand Down
Loading