|
1 | 1 | from gitlint.rules import LineRule, RuleViolation, CommitMessageTitle, CommitRule |
2 | 2 |
|
| 3 | + |
3 | 4 | class BodyContainsOnBehalfOfSAPMarker(CommitRule): |
4 | | - """Enforce that each commit coming from an SAP contractor contains an |
5 | | - "On-behalf-of SAP user@sap.com" marker. |
6 | | - """ |
| 5 | + """Enforce that each commit coming from an SAP contractor contains an |
| 6 | + "On-behalf-of SAP user@sap.com" marker. |
| 7 | + """ |
7 | 8 |
|
8 | | - # A rule MUST have a human friendly name |
9 | | - name = "body-requires-on-behalf-of-sap" |
| 9 | + # A rule MUST have a human friendly name |
| 10 | + name = "body-requires-on-behalf-of-sap" |
10 | 11 |
|
11 | | - # A rule MUST have a *unique* id |
12 | | - # We recommend starting with UC (for User-defined Commit-rule). |
13 | | - id = "UC-sap" |
| 12 | + # A rule MUST have a *unique* id |
| 13 | + # We recommend starting with UC (for User-defined Commit-rule). |
| 14 | + id = "UC-sap" |
14 | 15 |
|
15 | | - # Lower-case list of contractors |
16 | | - contractors = [ |
17 | | - "@cyberus-technology.de" |
18 | | - ] |
| 16 | + # Lower-case list of contractors |
| 17 | + contractors = ["@cyberus-technology.de"] |
19 | 18 |
|
20 | | - # Marker followed by " name.surname@sap.com" |
21 | | - marker = "On-behalf-of: SAP" |
| 19 | + # Marker followed by " name.surname@sap.com" |
| 20 | + marker = "On-behalf-of: SAP" |
22 | 21 |
|
23 | | - def validate(self, commit): |
24 | | - if "@sap.com" in commit.author_email.lower(): |
25 | | - return |
| 22 | + def validate(self, commit): |
| 23 | + if "@sap.com" in commit.author_email.lower(): |
| 24 | + return |
26 | 25 |
|
27 | | - # Allow third-party open-source contributions |
28 | | - if not any(contractor in commit.author_email.lower() for contractor in self.contractors): |
29 | | - return |
| 26 | + # Allow third-party open-source contributions |
| 27 | + if not any( |
| 28 | + contractor in commit.author_email.lower() for contractor in self.contractors |
| 29 | + ): |
| 30 | + return |
30 | 31 |
|
31 | | - for line in commit.message.body: |
32 | | - if line.startswith(self.marker) and "@sap.com" in line.lower(): |
33 | | - return |
| 32 | + for line in commit.message.body: |
| 33 | + if line.startswith(self.marker) and "@sap.com" in line.lower(): |
| 34 | + return |
34 | 35 |
|
35 | | - msg = f"Body does not contain a '{self.marker} user@sap.com' line" |
36 | | - return [RuleViolation(self.id, msg, line_nr=1)] |
| 36 | + msg = f"Body does not contain a '{self.marker} user@sap.com' line" |
| 37 | + return [RuleViolation(self.id, msg, line_nr=1)] |
0 commit comments