Skip to content

Commit

Permalink
gitlint: ignore titles prefixed with Revert
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nashif authored and Anas Nashif committed Aug 8, 2017
1 parent 408a61d commit 87766a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# All these sections are optional, edit this file as you like.
[general]
ignore=title-trailing-punctuation, T3
ignore=title-trailing-punctuation, T3, title-max-length, T1
# verbosity should be a value between 1 and 3, the commandline -v flags take precedence over this
verbosity = 3
# By default gitlint will ignore merge commits. Set to 'false' to disable.
Expand All @@ -12,13 +12,12 @@ debug = false
# See http://jorisroovers.github.io/gitlint/user_defined_rules for details
extra-path=scripts/gitlint

[title-max-length-no-revert]
line-length=72

[body-max-line-count]
max-line-count=200

[title-max-length]
line-length=72

[title-starts-with-subsystem]
regex = ^(([^:]+):)(\s([^:]+):)*\s(.+)$

Expand Down
11 changes: 11 additions & 0 deletions scripts/gitlint/zephyr_commit_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ def validate(self, commit):
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"
Expand Down

0 comments on commit 87766a2

Please sign in to comment.