Skip to content

Commit bc8d6c3

Browse files
committed
scripts: compliance: Avoid exception when commit message body is empty
Avoid the following exception in the Identity test when the commit body is empty: Traceback (most recent call last): File "zephyr/scripts/ci/check_compliance.py", line 2053, in main n_fails = _main(args) ^^^^^^^^^^^ File "zephyr/scripts/ci/check_compliance.py", line 1988, in _main test.run() File "zephyr/scripts/ci/check_compliance.py", line 1459, in run auth_name, auth_email, body = git( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: not enough values to unpack (expected 3, got 2) Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
1 parent 2f75fcb commit bc8d6c3

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

scripts/ci/check_compliance.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,17 +1456,24 @@ class Identity(ComplianceTest):
14561456

14571457
def run(self):
14581458
for shaidx in get_shas(COMMIT_RANGE):
1459-
auth_name, auth_email, body = git(
1460-
'show', '-s', '--format=%an%n%ae%n%b', shaidx
1461-
).split('\n', 2)
1459+
commit_info = git('show', '-s', '--format=%an%n%ae%n%b', shaidx).split('\n', 2)
1460+
1461+
failures = []
1462+
1463+
if len(commit_info) == 2:
1464+
failures.append(f'{shaidx}: Empty commit message body')
1465+
auth_name, auth_email = commit_info
1466+
body = ''
1467+
elif len(commit_info) == 3:
1468+
auth_name, auth_email, body = commit_info
1469+
else:
1470+
self.failure(f'Unable to parse commit message for {shaidx}')
14621471

14631472
match_signoff = re.search(r"signed-off-by:\s(.*)", body,
14641473
re.IGNORECASE)
14651474
detailed_match = re.search(r"signed-off-by:\s(.*) <(.*)>", body,
14661475
re.IGNORECASE)
14671476

1468-
failures = []
1469-
14701477
if auth_email.endswith("@users.noreply.github.com"):
14711478
failures.append(f"{shaidx}: author email ({auth_email}) must "
14721479
"be a real email and cannot end in "

0 commit comments

Comments
 (0)