|
6 | 6 |
|
7 | 7 | import argparse
|
8 | 8 | import collections
|
9 |
| -from email.utils import parseaddr |
10 | 9 | from itertools import takewhile
|
11 | 10 | import json
|
12 | 11 | import logging
|
@@ -1446,44 +1445,35 @@ class Identity(ComplianceTest):
|
1446 | 1445 |
|
1447 | 1446 | def run(self):
|
1448 | 1447 | for shaidx in get_shas(COMMIT_RANGE):
|
1449 |
| - commit = git("log", "--decorate=short", "--no-use-mailmap", "-n 1", shaidx) |
1450 |
| - signed = [] |
1451 |
| - author = "" |
1452 |
| - sha = "" |
1453 |
| - parsed_addr = None |
1454 |
| - for line in commit.split("\n"): |
1455 |
| - match = re.search(r"^commit\s([^\s]*)", line) |
1456 |
| - if match: |
1457 |
| - sha = match.group(1) |
1458 |
| - match = re.search(r"^Author:\s(.*)", line) |
1459 |
| - if match: |
1460 |
| - author = match.group(1) |
1461 |
| - parsed_addr = parseaddr(author) |
1462 |
| - match = re.search(r"signed-off-by:\s(.*)", line, re.IGNORECASE) |
1463 |
| - if match: |
1464 |
| - signed.append(match.group(1)) |
1465 |
| - |
1466 |
| - error1 = f"{sha}: author email ({author}) needs to match one of " \ |
1467 |
| - f"the signed-off-by entries." |
1468 |
| - error2 = f"{sha}: author email ({author}) does not follow the " \ |
1469 |
| - f"syntax: First Last <email>." |
1470 |
| - error3 = f"{sha}: author email ({author}) must be a real email " \ |
1471 |
| - f"and cannot end in @users.noreply.github.com" |
1472 |
| - failure = None |
1473 |
| - if author not in signed: |
1474 |
| - failure = error1 |
1475 |
| - |
1476 |
| - if not parsed_addr or len(parsed_addr[0].split(" ")) < 2: |
1477 |
| - if not failure: |
1478 |
| - |
1479 |
| - failure = error2 |
1480 |
| - else: |
1481 |
| - failure = failure + "\n" + error2 |
1482 |
| - elif parsed_addr[1].endswith("@users.noreply.github.com"): |
1483 |
| - failure = error3 |
1484 |
| - |
1485 |
| - if failure: |
1486 |
| - self.failure(failure) |
| 1448 | + auth_name, auth_email, body = git( |
| 1449 | + 'show', '-s', '--format=%an%n%ae%n%b', shaidx |
| 1450 | + ).split('\n', 2) |
| 1451 | + |
| 1452 | + match_signoff = re.search(r"signed-off-by:\s(.*)", body, |
| 1453 | + re.IGNORECASE) |
| 1454 | + detailed_match = re.search(r"signed-off-by:\s(.*) <(.*)>", body, |
| 1455 | + re.IGNORECASE) |
| 1456 | + |
| 1457 | + failures = [] |
| 1458 | + |
| 1459 | + if auth_email.endswith("@users.noreply.github.com"): |
| 1460 | + failures.append(f"{shaidx}: author email ({auth_email}) must " |
| 1461 | + "be a real email and cannot end in " |
| 1462 | + "@users.noreply.github.com") |
| 1463 | + |
| 1464 | + if not match_signoff: |
| 1465 | + failures.append(f'{shaidx}: Missing signed-off-by line') |
| 1466 | + elif not detailed_match: |
| 1467 | + signoff = match_signoff.group(0) |
| 1468 | + failures.append(f"{shaidx}: Signed-off-by line ({signoff}) " |
| 1469 | + "does not follow the syntax: First " |
| 1470 | + "Last <email>.") |
| 1471 | + elif (auth_name, auth_email) != detailed_match.groups(): |
| 1472 | + failures.append(f"{shaidx}: author email ({auth_email}) needs " |
| 1473 | + "to match one of the signed-off-by entries.") |
| 1474 | + |
| 1475 | + if failures: |
| 1476 | + self.failure('\n'.join(failures)) |
1487 | 1477 |
|
1488 | 1478 |
|
1489 | 1479 | class BinaryFiles(ComplianceTest):
|
|
0 commit comments