Skip to content

Commit 13dd2fb

Browse files
gitlint: screen userid from Signed-off-by
It is a common issue for new users to have a git-config that has a user id (either from their system or github) rather than a legal name matching an entry in their associated CLA. Screen these out in the gitlint check, so maintainers do not need to check this manually. Some individuals decide to go by a one word name. Provide an exception for this. Tested: ``` -: UC3 Signed-off-by user has too few words; likely user id instead of legal name?: "Signed-off-by: foo <[email protected]>" -: UC3 Invalid Signed-off-by format: "Signed-off-by: bar" ``` Signed-off-by: Patrick Williams <[email protected]> Change-Id: Ie87d640db8f0d223912f7c3b77545347020255ee
1 parent 9ce4de3 commit 13dd2fb

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

config/gitlint/bad_signedoffby.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import re
2+
3+
from gitlint.rules import CommitRule, RuleViolation
4+
5+
6+
class BadSignedOffBy(CommitRule):
7+
name = "bad-signed-off-by"
8+
id = "UC3"
9+
10+
# These are individuals, by email address, who chose to go by a one-word name.
11+
exceptions = ["[email protected]"]
12+
13+
def validate(self, commit):
14+
violations = []
15+
16+
sobs = [
17+
x for x in commit.message.body if x.startswith("Signed-off-by:")
18+
]
19+
for sob in sobs:
20+
match = re.search("Signed-off-by: (.*) <(.*)>", sob)
21+
if not match:
22+
violations.append(
23+
RuleViolation(self.id, "Invalid Signed-off-by format", sob)
24+
)
25+
continue
26+
27+
if (
28+
len(match.group(1).split()) <= 1
29+
and match.group(2) not in self.exceptions
30+
):
31+
violations.append(
32+
RuleViolation(
33+
self.id,
34+
"Signed-off-by user has too few words; likely user id instead of legal name?",
35+
sob,
36+
)
37+
)
38+
continue
39+
40+
return violations

0 commit comments

Comments
 (0)