Skip to content

Commit 9ce4de3

Browse files
gitlint: screen multiple change-ids
Tested: ``` $ ./scripts/format-code.sh --enable commit_gitlint Formatting code under .../openbmc-build-scripts Running commit_gitlint -: UC2 Multiple Change-Ids found in commit message body: "['Change-Id: Iec3501f75927d58bfe176423ce3eac824a0553d9', 'Change-Id: Iec3501f75927d58bfe176423ce3eac824a0553d9']" commit_gitlint: FAILED ``` Signed-off-by: Patrick Williams <[email protected]> Change-Id: Iec3501f75927d58bfe176423ce3eac824a0553d9
1 parent f0e5de9 commit 9ce4de3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

config/gitlint/multiple_change_id.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from gitlint.rules import CommitRule, RuleViolation
2+
3+
4+
class 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

0 commit comments

Comments
 (0)