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>
This commit is contained in:
Fabio Baltieri 2022-04-20 15:06:11 +01:00 committed by Anas Nashif
parent a30cf39975
commit d42b2e6bed

View file

@ -117,3 +117,16 @@ class MaxLineLengthExceptions(LineRule):
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