summaryrefslogtreecommitdiffstats
path: root/gitlint/tests/samples/user_rules/my_commit_rules.py
blob: 5456487f2b0ceb5625d6bc8e0d8e7fb31faed23c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-

from gitlint.rules import CommitRule, RuleViolation
from gitlint.options import IntOption


class MyUserCommitRule(CommitRule):
    name = u"my-üser-commit-rule"
    id = "UC1"
    options_spec = [IntOption('violation-count', 1, u"Number of violåtions to return")]

    def validate(self, _commit):
        violations = []
        for i in range(1, self.options['violation-count'].value + 1):
            violations.append(RuleViolation(self.id, u"Commit violåtion %d" % i, u"Contënt %d" % i, i))

        return violations


# The below code is present so that we can test that we actually ignore it

def func_should_be_ignored():
    pass


global_variable_should_be_ignored = True