Skip to content

Commit f48dda0

Browse files
nashifAnas Nashif
authored and
Anas Nashif
committed
ci: verify author identity
Make sure committers have correct and valid git settings and verify that the committer idenity matches one of the signed-off-by entries. Signed-off-by: Anas Nashif <[email protected]>
1 parent a48724f commit f48dda0

File tree

2 files changed

+49
-114
lines changed

2 files changed

+49
-114
lines changed

scripts/ci/check-compliance.py

+49-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import sh
99
import logging
1010
import argparse
11-
import check_identity
11+
#from check_identity import verify_signed_off
1212

1313
if "ZEPHYR_BASE" not in os.environ:
1414
logging.error("$ZEPHYR_BASE environment variable undefined.\n")
@@ -94,6 +94,50 @@ def run_checkpatch(tc, commit_range):
9494

9595
return 0
9696

97+
def verify_signed_off(tc, commit):
98+
99+
signed = []
100+
author = ""
101+
sha = ""
102+
parsed_addr = None
103+
for line in commit.split("\n"):
104+
match = re.search("^commit\s([^\s]*)", line)
105+
if match:
106+
sha = match.group(1)
107+
match = re.search("^Author:\s(.*)", line)
108+
if match:
109+
author = match.group(1)
110+
parsed_addr = parseaddr(author)
111+
match = re.search("signed-off-by:\s(.*)", line, re.IGNORECASE)
112+
if match:
113+
signed.append(match.group(1))
114+
115+
error1 = "%s: author email (%s) needs to match one of the signed-off-by entries." %(sha, author)
116+
error2 = "%s: author email (%s) does not follow the syntax: First Last <email>." %(sha, author)
117+
error = 0
118+
failure = None
119+
if author not in signed:
120+
failure = ET.SubElement(tc, 'failure', type="failure", message="identity error")
121+
failure.text = error1
122+
error = 1
123+
if not parsed_addr or len(parsed_addr[0].split(" ")) < 2:
124+
if not failure:
125+
failure = ET.SubElement(tc, 'failure', type="failure", message="identity error")
126+
failure.text = error2
127+
else:
128+
failure.text = failure.text + "\n" + error2
129+
error = 1
130+
131+
return error
132+
133+
def run_check_identity(tc, range):
134+
error = 0
135+
for f in get_shas(range):
136+
commit = sh.git("log","--decorate=short", "-n 1", f, **sh_special_args)
137+
error += verify_signed_off(tc, commit)
138+
139+
return error
140+
97141

98142
def check_doc(tc, range):
99143

@@ -114,6 +158,10 @@ def check_doc(tc, range):
114158
"call": run_gitlint,
115159
"name": "Commit message style",
116160
},
161+
"identity": {
162+
"call": run_check_identity,
163+
"name": "Author Identity verification",
164+
},
117165
"checkpatch": {
118166
"call": run_checkpatch,
119167
"name": "Code style check using checkpatch",

scripts/ci/check_identity.py

-113
This file was deleted.

0 commit comments

Comments
 (0)