summaryrefslogtreecommitdiffstats
path: root/examples/my_configuration_rules.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/my_configuration_rules.py')
-rw-r--r--examples/my_configuration_rules.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/examples/my_configuration_rules.py b/examples/my_configuration_rules.py
index 7715c0b..50abd56 100644
--- a/examples/my_configuration_rules.py
+++ b/examples/my_configuration_rules.py
@@ -29,15 +29,17 @@ class ReleaseConfigurationRule(ConfigurationRule):
# A rule MUST have a human friendly name
name = "release-configuration-rule"
- # A rule MUST have a *unique* id, we recommend starting with UCR
- # (for User-defined Configuration-Rule), but this can really be anything.
+ # A rule MUST have a *unique* id
+ # We recommend starting with UCR (for User-defined Configuration-Rule)
id = "UCR1"
# A rule MAY have an option_spec if its behavior should be configurable.
- options_spec = [IntOption("custom-verbosity", 2, "Gitlint verbosity for release commits")]
+ options_spec = [
+ IntOption("custom-verbosity", 2, "Verbosity for release commits"),
+ ]
def apply(self, config, commit):
- self.log.debug("ReleaseConfigurationRule: This will be visible when running `gitlint --debug`")
+ self.log.debug("This 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
@@ -56,14 +58,16 @@ class ReleaseConfigurationRule(ConfigurationRule):
# To set general options use
# config.set_general_option(<general-option>, <value>)
config.set_general_option("verbosity", 2)
- # Wwe can also use custom options to make this configurable
- config.set_general_option("verbosity", self.options["custom-verbosity"].value)
+ # We can also use custom options to make this configurable
+ custom_verbosity = self.options["custom-verbosity"].value
+ config.set_general_option("verbosity", custom_verbosity)
# Strip any lines starting with $ from the commit message
- # (this only affects how gitlint sees your commit message, it does
- # NOT modify your actual commit in git)
- commit.message.body = [line for line in commit.message.body if not line.startswith("$")]
+ # (this only affects how gitlint sees your commit message,
+ # it does NOT modify your actual commit in git)
+ body = [l for l in commit.message.body if not l.startswith("$")]
+ commit.message.body = body
- # You can add any extra properties you want to the commit object, these will be available later on
- # in all rules.
+ # You can add any extra properties you want to the commit object,
+ # these will be available later on in all rules.
commit.my_property = "This is my property"