scripts: gitlint: block Change-Id tags in commit message
Add a new gitlint user rule to block unwanted commit tags, and set it up
to block Gerrit Change-Id tags.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
diff --git a/scripts/gitlint/zephyr_commit_rules.py b/scripts/gitlint/zephyr_commit_rules.py
index 915f085..cfbfbdc 100644
--- a/scripts/gitlint/zephyr_commit_rules.py
+++ b/scripts/gitlint/zephyr_commit_rules.py
@@ -117,3 +117,16 @@
if len(line) > max_length:
return [RuleViolation(self.id, self.violation_message.format(len(line), max_length), line)]
+
+class BodyContainsBlockedTags(LineRule):
+ name = "body-contains-blocked-tags"
+ id = "UC7"
+ target = CommitMessageBody
+ tags = ["Change-Id"]
+
+ def validate(self, line, _commit):
+ flags = re.IGNORECASE
+ for tag in self.tags:
+ if re.search(rf"^\s*{tag}:", line, flags=flags):
+ return [RuleViolation(self.id, f"Body contains a blocked tag: {tag}")]
+ return