diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-19 14:52:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-19 14:52:46 +0000 |
commit | a2aa51f5702b18016c25d943499941323952704d (patch) | |
tree | 7ee43f79639ee53903e7ca389e548974e1497c3a /examples/my_commit_rules.py | |
parent | Adding upstream version 0.17.0. (diff) | |
download | gitlint-a2aa51f5702b18016c25d943499941323952704d.tar.xz gitlint-a2aa51f5702b18016c25d943499941323952704d.zip |
Adding upstream version 0.18.0.upstream/0.18.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'examples/my_commit_rules.py')
-rw-r--r-- | examples/my_commit_rules.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/examples/my_commit_rules.py b/examples/my_commit_rules.py index 2805501..35bb836 100644 --- a/examples/my_commit_rules.py +++ b/examples/my_commit_rules.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from gitlint.rules import CommitRule, RuleViolation from gitlint.options import IntOption, ListOption @@ -27,20 +25,20 @@ class BodyMaxLineCount(CommitRule): id = "UC1" # A rule MAY have an option_spec if its behavior should be configurable. - options_spec = [IntOption('max-line-count', 3, "Maximum body line count")] + options_spec = [IntOption("max-line-count", 3, "Maximum body line count")] def validate(self, commit): self.log.debug("BodyMaxLineCount: This will be visible when running `gitlint --debug`") line_count = len(commit.message.body) - max_line_count = self.options['max-line-count'].value + max_line_count = self.options["max-line-count"].value if line_count > max_line_count: message = f"Body contains too many lines ({line_count} > {max_line_count})" return [RuleViolation(self.id, message, line_nr=1)] class SignedOffBy(CommitRule): - """ This rule will enforce that each commit contains a "Signed-off-by" line. + """This rule will enforce that each commit contains a "Signed-off-by" line. We keep things simple here and just check whether the commit body contains a line that starts with "Signed-off-by". """ @@ -61,8 +59,8 @@ class SignedOffBy(CommitRule): class BranchNamingConventions(CommitRule): - """ This rule will enforce that a commit is part of a branch that meets certain naming conventions. - See GitFlow for real-world example of this: https://nvie.com/posts/a-successful-git-branching-model/ + """This rule will enforce that a commit is part of a branch that meets certain naming conventions. + See GitFlow for real-world example of this: https://nvie.com/posts/a-successful-git-branching-model/ """ # A rule MUST have a human friendly name @@ -72,13 +70,13 @@ class BranchNamingConventions(CommitRule): id = "UC3" # A rule MAY have an option_spec if its behavior should be configurable. - options_spec = [ListOption('branch-prefixes', ["feature/", "hotfix/", "release/"], "Allowed branch prefixes")] + options_spec = [ListOption("branch-prefixes", ["feature/", "hotfix/", "release/"], "Allowed branch prefixes")] def validate(self, commit): self.log.debug("BranchNamingConventions: This line will be visible when running `gitlint --debug`") violations = [] - allowed_branch_prefixes = self.options['branch-prefixes'].value + allowed_branch_prefixes = self.options["branch-prefixes"].value for branch in commit.branches: valid_branch_name = False |