Skip to content

Commit

Permalink
.github/request-reviews.yml: Formatting (non-functional)
Browse files Browse the repository at this point in the history
Updates code for PEP8 formatting by using the Black code formatter.

Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
makubacki authored and mergify[bot] committed Aug 5, 2024
1 parent 32a099c commit 59ad8ae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
12 changes: 8 additions & 4 deletions .github/scripts/GitHub.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def get_reviewers_for_range(
)
if cmd_ret != 0:
print(
f"::error title=Reviewer Lookup Error!::Error calling GetMaintainer.py: [{cmd_ret}]: {reviewer_stream_buffer.getvalue()}"
f"::error title=Reviewer Lookup Error!::Error calling "
f"GetMaintainer.py: [{cmd_ret}]: "
f"{reviewer_stream_buffer.getvalue()}"
)
return []

Expand All @@ -138,7 +140,8 @@ def get_reviewers_for_range(
return []

print(
f"::debug title=Commit {commit_sha[:7]} Reviewer(s)::{', '.join(matches)}"
f"::debug title=Commit {commit_sha[:7]} "
f"Reviewer(s)::{', '.join(matches)}"
)

raw_reviewers.extend(matches)
Expand Down Expand Up @@ -232,8 +235,9 @@ def add_reviewers_to_pr(
# Notify the admins of the repository if non-collaborators are requested.
if non_collaborators:
print(
f"::warning title=Non-Collaborator Reviewers Found!::{', '.join(non_collaborators)}"
)
f"::warning title=Non-Collaborator Reviewers Found!::"
f"{', '.join(non_collaborators)}"
)

for comment in pr.get_issue_comments():
# If a comment has already been made for these non-collaborators,
Expand Down
24 changes: 18 additions & 6 deletions .github/workflows/request-reviews.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,36 @@ jobs:
import git
import os
import sys
sys.path.append(os.path.join(os.environ['WORKSPACE_PATH'], ".github"))
sys.path.append(os.path.join(os.environ["WORKSPACE_PATH"], ".github"))
from scripts import GitHub
WORKSPACE_PATH = os.environ['WORKSPACE_PATH']
GET_MAINTAINER_LOCAL_PATH = os.path.join(WORKSPACE_PATH, os.environ['GET_MAINTAINER_REL_PATH'])
WORKSPACE_PATH = os.environ["WORKSPACE_PATH"]
GET_MAINTAINER_LOCAL_PATH = os.path.join(
WORKSPACE_PATH, os.environ["GET_MAINTAINER_REL_PATH"]
)
# Step 1: Get the GitHub created PR commit SHA (contains all changes in a single commit)
pr_commit_sha = GitHub.get_pr_sha(os.environ['GH_TOKEN'], os.environ['ORG_NAME'], os.environ['REPO_NAME'], int(os.environ['PR_NUMBER']))
pr_commit_sha = GitHub.get_pr_sha(
os.environ["GH_TOKEN"],
os.environ["ORG_NAME"],
os.environ["REPO_NAME"],
int(os.environ["PR_NUMBER"]),
)
if not pr_commit_sha:
sys.exit(1)
print(f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: {pr_commit_sha}")
print(
f"::notice title=PR Commit SHA::Looking at files in consolidated PR commit: {pr_commit_sha}"
)
# Step 2: Fetch only the PR commit to get the files changed in the PR
git.Repo(WORKSPACE_PATH).remotes.origin.fetch(pr_commit_sha, depth=1)
# Step 3: Get the list of reviewers for the PR
reviewers = GitHub.get_reviewers_for_range(WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha)
reviewers = GitHub.get_reviewers_for_range(
WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha
)
if not reviewers:
print("::notice title=No New Reviewers Found!::No reviewers found for this PR.")
sys.exit(0)
Expand Down

0 comments on commit 59ad8ae

Please sign in to comment.