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:
parent
a30cf39975
commit
d42b2e6bed
1 changed files with 13 additions and 0 deletions
|
@ -117,3 +117,16 @@ class MaxLineLengthExceptions(LineRule):
|
||||||
|
|
||||||
if len(line) > max_length:
|
if len(line) > max_length:
|
||||||
return [RuleViolation(self.id, self.violation_message.format(len(line), max_length), line)]
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue