summaryrefslogtreecommitdiffstats
path: root/qa/samples
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-25 13:26:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-25 13:26:35 +0000
commit4fee3e091a8d79a40f70ff9c1f87b29b9340049a (patch)
tree465ad9629a8ee56548bd6c51c3fc710907564911 /qa/samples
parentReleasing debian version 0.14.0-1. (diff)
downloadgitlint-4fee3e091a8d79a40f70ff9c1f87b29b9340049a.tar.xz
gitlint-4fee3e091a8d79a40f70ff9c1f87b29b9340049a.zip
Merging upstream version 0.15.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qa/samples')
-rw-r--r--qa/samples/user_rules/extra/extra_rules.py33
1 files changed, 16 insertions, 17 deletions
diff --git a/qa/samples/user_rules/extra/extra_rules.py b/qa/samples/user_rules/extra/extra_rules.py
index 6fb985f..9a0ae6d 100644
--- a/qa/samples/user_rules/extra/extra_rules.py
+++ b/qa/samples/user_rules/extra/extra_rules.py
@@ -2,18 +2,17 @@
from gitlint.rules import CommitRule, RuleViolation, ConfigurationRule
from gitlint.options import IntOption, StrOption, ListOption
-from gitlint.utils import sstr
class GitContextRule(CommitRule):
""" Rule that tests whether we can correctly access certain gitcontext properties """
- name = u"gïtcontext"
+ name = "gïtcontext"
id = "UC1"
def validate(self, commit):
violations = [
- RuleViolation(self.id, u"GitContext.current_branch: {0}".format(commit.context.current_branch), line_nr=1),
- RuleViolation(self.id, u"GitContext.commentchar: {0}".format(commit.context.commentchar), line_nr=1)
+ RuleViolation(self.id, f"GitContext.current_branch: {commit.context.current_branch}", line_nr=1),
+ RuleViolation(self.id, f"GitContext.commentchar: {commit.context.commentchar}", line_nr=1)
]
return violations
@@ -21,13 +20,13 @@ class GitContextRule(CommitRule):
class GitCommitRule(CommitRule):
""" Rule that tests whether we can correctly access certain commit properties """
- name = u"gïtcommit"
+ name = "gïtcommit"
id = "UC2"
def validate(self, commit):
violations = [
- RuleViolation(self.id, u"GitCommit.branches: {0}".format(sstr(commit.branches)), line_nr=1),
- RuleViolation(self.id, u"GitCommit.custom_prop: {0}".format(commit.custom_prop), line_nr=1),
+ RuleViolation(self.id, f"GitCommit.branches: {commit.branches}", line_nr=1),
+ RuleViolation(self.id, f"GitCommit.custom_prop: {commit.custom_prop}", line_nr=1),
]
return violations
@@ -35,16 +34,16 @@ class GitCommitRule(CommitRule):
class GitlintConfigurationRule(ConfigurationRule):
""" Rule that tests whether we can correctly access the config as well as modify the commit message """
- name = u"cönfigrule"
+ name = "cönfigrule"
id = "UC3"
def apply(self, config, commit):
# We add a line to the commit message body that pulls a value from config, this proves we can modify the body
# and read the config contents
- commit.message.body.append("{0} ".format(config.target)) # trailing whitespace deliberate to trigger violation
+ commit.message.body.append(f"{config.target} ") # trailing whitespace deliberate to trigger violation
# We set a custom property that we access in CommitRule, to prove we can add extra properties to the commit
- commit.custom_prop = u"foöbar"
+ commit.custom_prop = "foöbar"
# We also ignore some extra rules, proving that we can modify the config
config.ignore.append("B4")
@@ -52,18 +51,18 @@ class GitlintConfigurationRule(ConfigurationRule):
class ConfigurableCommitRule(CommitRule):
""" Rule that tests that we can add configuration to user-defined rules """
- name = u"configürable"
+ name = "configürable"
id = "UC4"
- options_spec = [IntOption(u"int-öption", 2, u"int-öption description"),
- StrOption(u"str-öption", u"föo", u"int-öption description"),
- ListOption(u"list-öption", [u"foo", u"bar"], u"list-öption description")]
+ options_spec = [IntOption("int-öption", 2, "int-öption description"),
+ StrOption("str-öption", "föo", "int-öption description"),
+ ListOption("list-öption", ["foo", "bar"], "list-öption description")]
def validate(self, _):
violations = [
- RuleViolation(self.id, u"int-öption: {0}".format(self.options[u'int-öption'].value), line_nr=1),
- RuleViolation(self.id, u"str-öption: {0}".format(self.options[u'str-öption'].value), line_nr=1),
- RuleViolation(self.id, u"list-öption: {0}".format(sstr(self.options[u'list-öption'].value)), line_nr=1),
+ RuleViolation(self.id, f"int-öption: {self.options[u'int-öption'].value}", line_nr=1),
+ RuleViolation(self.id, f"str-öption: {self.options[u'str-öption'].value}", line_nr=1),
+ RuleViolation(self.id, f"list-öption: {self.options[u'list-öption'].value}", line_nr=1),
]
return violations