# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.1# SPDX-License-Identifier: Apache-2.02"""The user defined rules for gitlint."""34from gitlint.rules import CommitRule, RuleViolation567class SignedOffBy(CommitRule):8"""Make sure that each commit contains a "Signed-off-by" line."""910# The name of the rule.11name = "body-requires-signed-off-by"1213# The unique id of the rule.14id = "UC2"1516def validate(self, commit):17"""Validate user defined gitlint rules."""18for line in commit.message.body:19if line.startswith("Signed-off-by"):20return []2122msg = "Body does not contain a 'Signed-off-by' line"23return [RuleViolation(self.id, msg, line_nr=1)]242526