xref: /openbmc/openbmc-build-scripts/config/gitlint/multiple_change_id.py (revision cf184a41f5fe3e6c37c420f6aaece634b62e47ec)
1from gitlint.rules import CommitRule, RuleViolation
2
3
4class DuplicateChangeIdEntries(CommitRule):
5    name = "duplicate-change-id-entries"
6    id = "UC2"
7
8    def validate(self, commit):
9        change_ids = [
10            x for x in commit.message.body if x.startswith("Change-Id:")
11        ]
12        if len(change_ids) > 1:
13            return [
14                RuleViolation(
15                    self.id,
16                    "Multiple Change-Ids found in commit message body",
17                    change_ids,
18                )
19            ]
20
21        return None
22