diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2024-11-25 12:24:25 -0500 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-11-26 18:08:26 +0000 |
commit | a4c50dd3e89cb304a0861f8e93ff06b5d0f9861e (patch) | |
tree | 8b6ffc4dfcf1dadfae7c17e691f36994d21054d3 | |
parent | 7eff71fe690a0f5bc0be67b5b83f263d7892f9b6 (diff) | |
download | edk2-a4c50dd3e89cb304a0861f8e93ff06b5d0f9861e.tar.gz |
.github: Handle deleted GitHub accounts
If a GitHub account has been deleted entirely, a `None` user will
be returrned from the GitHub API. This change accounts for a `None`
user when querying GitHub APIs for user information.
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
-rw-r--r-- | .github/scripts/GitHub.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index 885975a7d7..052fbf8428 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -218,15 +218,17 @@ def add_reviewers_to_pr( # The current PR reviewers do not need to be requested again.
current_pr_requested_reviewers = [
- r.login.strip() for r in pr.get_review_requests()[0]
+ r.login.strip() for r in pr.get_review_requests()[0] if r
+ ]
+ current_pr_reviewed_reviewers = [
+ r.user.login.strip() for r in pr.get_reviews() if r and r.user
]
- current_pr_reviewed_reviewers = [r.user.login.strip() for r in pr.get_reviews()]
current_pr_reviewers = list(
set(current_pr_requested_reviewers + current_pr_reviewed_reviewers)
)
# A user can only be added if they are a collaborator of the repository.
- repo_collaborators = [c.login.strip() for c in repo_gh.get_collaborators()]
+ repo_collaborators = [c.login.strip() for c in repo_gh.get_collaborators() if c]
non_collaborators = [u for u in user_names if u not in repo_collaborators]
excluded_pr_reviewers = [pr_author] + current_pr_reviewers + non_collaborators
@@ -243,14 +245,15 @@ def add_reviewers_to_pr( # If a comment has already been made for these non-collaborators,
# do not make another comment.
if (
- comment.user.login == "tianocore-assign-reviewers[bot]"
+ comment.user
+ and comment.user.login == "tianocore-assign-reviewers[bot]"
and "WARNING: Cannot add some reviewers" in comment.body
and all(u in comment.body for u in non_collaborators)
):
break
else:
repo_admins = [
- a.login for a in repo_gh.get_collaborators(permission="admin")
+ a.login for a in repo_gh.get_collaborators(permission="admin") if a
]
leave_pr_comment(
|