summaryrefslogtreecommitdiffstats
path: root/gitlint-core/gitlint/contrib/rules/signedoff_by.py
blob: 5ea8217ab775b1f4f158add737d92d596b857906 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from gitlint.rules import CommitRule, RuleViolation


class SignedOffBy(CommitRule):
    """This rule will enforce that each commit body contains a "Signed-off-by" line.
    We keep things simple here and just check whether the commit body contains a line that starts with "Signed-off-by".
    """

    name = "contrib-body-requires-signed-off-by"
    id = "CC1"

    def validate(self, commit):
        for line in commit.message.body:
            if line.lower().startswith("signed-off-by"):
                return []

        return [RuleViolation(self.id, "Body does not contain a 'Signed-off-by' line", line_nr=1)]