1
0
Fork 0

Merging upstream version 0.14.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 06:02:10 +01:00
parent 4c68f51a53
commit e916bee311
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
109 changed files with 2822 additions and 912 deletions

View file

@ -1,7 +1,11 @@
# -*- coding: utf-8 -*-
from gitlint.rules import LineRule, RuleViolation, CommitMessageTitle
from gitlint.options import ListOption
"""
Full details on user-defined rules: https://jorisroovers.com/gitlint/user_defined_rules
The SpecialChars class below is an example of a user-defined LineRule. Line rules are gitlint rules that only act on a
single line at once. Once the rule is discovered, gitlint will automatically take care of applying this rule
against each line of the commit message title or body (whether it is applied to the title or body is determined by the
@ -35,11 +39,14 @@ class SpecialChars(LineRule):
"Comma separated list of characters that should not occur in the title")]
def validate(self, line, _commit):
self.log.debug("SpecialChars: This will be visible when running `gitlint --debug`")
violations = []
# options can be accessed by looking them up by their name in self.options
for char in self.options['special-chars'].value:
if char in line:
violation = RuleViolation(self.id, "Title contains the special character '{0}'".format(char), line)
msg = "Title contains the special character '{0}'".format(char)
violation = RuleViolation(self.id, msg, line)
violations.append(violation)
return violations