8
8
import sh
9
9
import logging
10
10
import argparse
11
- import check_identity
11
+ #from check_identity import verify_signed_off
12
12
13
13
if "ZEPHYR_BASE" not in os .environ :
14
14
logging .error ("$ZEPHYR_BASE environment variable undefined.\n " )
@@ -94,6 +94,50 @@ def run_checkpatch(tc, commit_range):
94
94
95
95
return 0
96
96
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
+
97
141
98
142
def check_doc (tc , range ):
99
143
@@ -114,6 +158,10 @@ def check_doc(tc, range):
114
158
"call" : run_gitlint ,
115
159
"name" : "Commit message style" ,
116
160
},
161
+ "identity" : {
162
+ "call" : run_check_identity ,
163
+ "name" : "Author Identity verification" ,
164
+ },
117
165
"checkpatch" : {
118
166
"call" : run_checkpatch ,
119
167
"name" : "Code style check using checkpatch" ,
0 commit comments