-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflows: Added commit message formating
Signed-off-by: Lorenzo Vagliano
- Loading branch information
1 parent
1dd37aa
commit 484a161
Showing
5 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,3 @@ jobs: | |
|
||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[general] | ||
ignore=body-is-missing | ||
extra-path=./scripts/gitlint_rules/ | ||
debug=true | ||
verbosity=3 | ||
|
||
[title-max-length] | ||
line-length=50 | ||
|
||
[body-max-line-length] | ||
line-length=72 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import re | ||
|
||
from gitlint.rules import CommitRule, RuleViolation | ||
|
||
class SignedOffBy(CommitRule): | ||
"""This rule will enforce that each commit contains a "Signed-off-by" line.""" | ||
|
||
name = "body-requires-signed-off-by" | ||
id = "Workflows1" | ||
|
||
def validate(self, commit): | ||
for line in commit.message.body: | ||
if line.startswith("Signed-off-by"): | ||
return | ||
|
||
msg = "Body does not contain a 'Signed-Off-By' line" | ||
return [RuleViolation(self.id, msg, line_nr=1)] | ||
|
||
|
||
class ApprovedSubject(CommitRule): | ||
"""Validate subject of each commit. | ||
This rule will enforce that each commit starts with a "module: text" format. | ||
The 'module' can be any alphanumeric word, and the message must start with a colon followed by a space. | ||
""" | ||
|
||
name = "approved-subject-in-title" | ||
id = "Workflows2" | ||
|
||
MODULE_PATTERN = re.compile(r"^[a-zA-Z0-9_-]+: .+") | ||
|
||
def validate(self, commit): | ||
title = commit.message.title | ||
|
||
if not self.MODULE_PATTERN.match(title): | ||
msg = "Subject does not follow 'module: text' format" | ||
return [RuleViolation(self.id, msg, line_nr=1)] | ||
|
||
return |