Lines Matching +full:commit +full:- +full:message

1 # SPDX-License-Identifier: Apache-2.0
4 The classes below are examples of user-defined CommitRules. Commit rules are gitlint rules that
5 act on the entire commit at once. Once the rules are discovered, gitlint will automatically take ca…
6 to the entire commit. This happens exactly once per commit.
8 A CommitRule contrasts with a LineRule (see examples/my_line_rules.py) in that a commit rule is onl…
9 an entire commit. This allows commit rules to implement more complex checks that span multiple line…
22 name = "body-min-line-count"
24 # A rule MUST have an *unique* id, we recommend starting with UC (for User-defined Commit-rule).
28 … options_spec = [IntOption('min-line-count', 1, "Minimum body line count excluding Signed-off-by")]
30 def validate(self, commit): argument
31 …filtered = [x for x in commit.message.body if not x.lower().startswith("signed-off-by") and x != '…
33 min_line_count = self.options['min-line-count'].value
35message = "Commit message body is empty, should at least have {} line(s).".format(min_line_count)
36 return [RuleViolation(self.id, message, line_nr=1)]
40 name = "body-max-line-count"
42 # A rule MUST have an *unique* id, we recommend starting with UC (for User-defined Commit-rule).
46 options_spec = [IntOption('max-line-count', 200, "Maximum body line count")]
48 def validate(self, commit): argument
49 line_count = len(commit.message.body)
50 max_line_count = self.options['max-line-count'].value
52message = "Commit message body contains too many lines ({0} > {1})".format(line_count, max_line_co…
53 return [RuleViolation(self.id, message, line_nr=1)]
56 """ This rule will enforce that each commit contains a "Signed-off-by" line.
57 …p things simple here and just check whether the commit body contains a line that starts with "Sign…
61 name = "body-requires-signed-off-by"
63 # A rule MUST have an *unique* id, we recommend starting with UC (for User-defined Commit-rule).
66 def validate(self, commit): argument
69 for line in commit.message.body:
70 if line.lower().startswith("signed-off-by"):
71 … if not re.search(r"(^)Signed-off-by: ([-'\w.]+) ([-'\w.]+) (.*)", line, flags=flags):
72 … return [RuleViolation(self.id, "Signed-off-by: must have a full name", line_nr=1)]
75 …return [RuleViolation(self.id, "Commit message does not contain a 'Signed-off-by:' line", line_nr=…
78 name = "title-max-length-no-revert"
81 options_spec = [IntOption('line-length', 75, "Max line length")]
82 violation_message = "Commit title exceeds max length ({0}>{1})"
85 max_length = self.options['line-length'].value
90 name = "title-starts-with-subsystem"
98 …violation_message = "Commit title does not follow [subsystem]: [subject] (and should not start wit…
103 name = "max-line-length-with-exceptions"
106 options_spec = [IntOption('line-length', 75, "Max line length")]
107 violation_message = "Commit message body line exceeds max length ({0}>{1})"
110 max_length = self.options['line-length'].value
111 …urls = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+…
112 if line.lower().startswith('signed-off-by') or line.lower().startswith('co-authored-by'):
122 name = "body-contains-blocked-tags"
125 tags = ["Change-Id"]
131 return [RuleViolation(self.id, f"Commit message contains a blocked tag: {tag}")]