From 624934b05b0817c085adedac07c711386bcc9591 Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Wed, 21 Dec 2022 18:16:58 +0000 Subject: [PATCH] CLA: Handle commits with no author information --- .github/workflows/check-cla.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-cla.yml b/.github/workflows/check-cla.yml index 8e2f31348e..70d082413d 100644 --- a/.github/workflows/check-cla.yml +++ b/.github/workflows/check-cla.yml @@ -10,7 +10,6 @@ jobs: run: | import urllib.request import json - import itertools import sys def jsonRequest(url, data={}): req = urllib.request.Request(url, @@ -19,9 +18,12 @@ jobs: with urllib.request.urlopen(req) as response: return json.loads(response.read().decode('utf-8')) prCommits = jsonRequest('https://api.github.com/repos/juce-framework/JUCE/pulls/${{ github.event.number }}/commits') - authors = map(lambda commit: [commit['author']['login'], commit['committer']['login']], prCommits) - uniqueAuthors = [name for name in list(set(itertools.chain.from_iterable(authors))) if name != 'web-flow'] - print(f'\nPR authors: {", ".join(uniqueAuthors)}') + allAuthors = [commit[authorType]['login'] for authorType in ['author', 'committer'] for commit in prCommits if commit[authorType]] + uniqueAuthors = [name for name in list(set(allAuthors)) if name != 'web-flow'] + if (len(uniqueAuthors) == 0): + print(f'\nNo author or committer user IDs contained within commit information\n\n{prCommits}\n') + sys.exit(1) + print(f'Authors: {uniqueAuthors}') claResult = jsonRequest('https://cla.juce.com/check', {'logins': uniqueAuthors}) unsignedLogins = claResult['unsigned'] if (len(unsignedLogins) != 0):