diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-11-03 06:07:45 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-11-03 06:07:45 +0000 |
commit | 5f208e04c159791e668031a7fa83f98724ec8d24 (patch) | |
tree | 4b58b42fd2a91a14871010e2dd39369a839ae383 /examples/my_line_rules.py | |
parent | Adding upstream version 0.13.1. (diff) | |
download | gitlint-5f208e04c159791e668031a7fa83f98724ec8d24.tar.xz gitlint-5f208e04c159791e668031a7fa83f98724ec8d24.zip |
Adding upstream version 0.14.0.upstream/0.14.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | examples/my_line_rules.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/my_line_rules.py b/examples/my_line_rules.py index cc69fb9..820024a 100644 --- a/examples/my_line_rules.py +++ b/examples/my_line_rules.py @@ -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 |