summaryrefslogtreecommitdiffstats
path: root/qa/samples/user_rules/extra/extra_rules.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-03-19 14:00:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2020-03-19 14:00:14 +0000
commitdf9615bac55ac6f1c3f516b66279ac0007175030 (patch)
tree84dd81d1c97835271cea7fbdd67c074742365e07 /qa/samples/user_rules/extra/extra_rules.py
parentInitial commit. (diff)
downloadgitlint-df9615bac55ac6f1c3f516b66279ac0007175030.tar.xz
gitlint-df9615bac55ac6f1c3f516b66279ac0007175030.zip
Adding upstream version 0.13.1.upstream/0.13.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qa/samples/user_rules/extra/extra_rules.py')
-rw-r--r--qa/samples/user_rules/extra/extra_rules.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/qa/samples/user_rules/extra/extra_rules.py b/qa/samples/user_rules/extra/extra_rules.py
new file mode 100644
index 0000000..8109299
--- /dev/null
+++ b/qa/samples/user_rules/extra/extra_rules.py
@@ -0,0 +1,29 @@
+from gitlint.rules import CommitRule, RuleViolation
+from gitlint.utils import sstr
+
+
+class GitContextRule(CommitRule):
+ """ Rule that tests whether we can correctly access certain gitcontext properties """
+ name = "gitcontext"
+ id = "UC1"
+
+ def validate(self, commit):
+ violations = [
+ RuleViolation(self.id, "GitContext.current_branch: {0}".format(commit.context.current_branch), line_nr=1),
+ RuleViolation(self.id, "GitContext.commentchar: {0}".format(commit.context.commentchar), line_nr=1)
+ ]
+
+ return violations
+
+
+class GitCommitRule(CommitRule):
+ """ Rule that tests whether we can correctly access certain commit properties """
+ name = "gitcommit"
+ id = "UC2"
+
+ def validate(self, commit):
+ violations = [
+ RuleViolation(self.id, "GitCommit.branches: {0}".format(sstr(commit.branches)), line_nr=1),
+ ]
+
+ return violations