diff options
author | Joris Roovers <joris.roovers@gmail.com> | 2020-09-04 13:15:46 +0200 |
---|---|---|
committer | Joris Roovers <joris.roovers@gmail.com> | 2020-09-04 13:15:46 +0200 |
commit | 96faf902472de952ad73c47b93e7a79df04dc67a (patch) | |
tree | 4a2d00b830426d0cf6a6dbbe097ca8a2a7e73006 /examples | |
parent | 9a8cce3c0d33e1da5618f744b9dfd0182bcc0a2f (diff) |
self.log for easily logging in user-defined rules
Users can now use `self.log` to easily log messages in their user-defined
rules.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/my_commit_rules.py | 6 | ||||
-rw-r--r-- | examples/my_configuration_rules.py | 1 | ||||
-rw-r--r-- | examples/my_line_rules.py | 2 |
3 files changed, 9 insertions, 0 deletions
diff --git a/examples/my_commit_rules.py b/examples/my_commit_rules.py index b056bcf..97edf4d 100644 --- a/examples/my_commit_rules.py +++ b/examples/my_commit_rules.py @@ -32,6 +32,8 @@ class BodyMaxLineCount(CommitRule): options_spec = [IntOption('max-line-count', 3, "Maximum body line count")] def validate(self, commit): + self.log.debug("BodyMaxLineCount: This line will be visible when running `gitlint --debug`") + line_count = len(commit.message.body) max_line_count = self.options['max-line-count'].value if line_count > max_line_count: @@ -51,6 +53,8 @@ class SignedOffBy(CommitRule): id = "UC2" def validate(self, commit): + self.log.debug("SignedOffBy: This line will be visible when running `gitlint --debug`") + for line in commit.message.body: if line.startswith("Signed-Off-By"): return @@ -73,6 +77,8 @@ class BranchNamingConventions(CommitRule): 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 for branch in commit.branches: diff --git a/examples/my_configuration_rules.py b/examples/my_configuration_rules.py index 872440f..f153b5e 100644 --- a/examples/my_configuration_rules.py +++ b/examples/my_configuration_rules.py @@ -39,6 +39,7 @@ class ReleaseConfigurationRule(ConfigurationRule): options_spec = [IntOption('custom-verbosity', 2, "Gitlint verbosity for release commits")] def apply(self, config, commit): + self.log.debug("ReleaseConfigurationRule: This line will be visible when running `gitlint --debug`") # If the commit title starts with 'Release', we want to modify # how all subsequent rules interpret that commit diff --git a/examples/my_line_rules.py b/examples/my_line_rules.py index 1387d4d..1c9ae6c 100644 --- a/examples/my_line_rules.py +++ b/examples/my_line_rules.py @@ -39,6 +39,8 @@ 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 line 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: |