.github/request-reviews.yml: Switch to GitPython

Uses `GitPython` instead of invoking the git executable directly.

This has the benefit of improving code readability and less support
code for binary interaction.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit is contained in:
Michael Kubacki
2024-07-31 18:28:27 -04:00
committed by mergify[bot]
parent 057c26710a
commit 98f17cdcf4
3 changed files with 10 additions and 31 deletions

View File

@@ -5,12 +5,13 @@
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
import git
import logging
import re
import requests
from collections import OrderedDict
from edk2toollib.utility_functions import RunCmd, RunPythonScript
from edk2toollib.utility_functions import RunPythonScript
from io import StringIO
from typing import List
@@ -59,24 +60,15 @@ def get_reviewers_for_range(
Returns:
List[str]: A list of GitHub usernames.
"""
if range_start == range_end:
commits = [range_start]
else:
commit_stream_buffer = StringIO()
cmd_ret = RunCmd(
"git",
f"log --format=format:%H {range_start}..{range_end}",
workingdir=workspace_path,
outstream=commit_stream_buffer,
logging_level=logging.INFO,
)
if cmd_ret != 0:
print(
f"::error title=Commit Lookup Error!::Error getting branch commits: [{cmd_ret}]: {commit_stream_buffer.getvalue()}"
commits = [
c.hexsha
for c in git.Repo(workspace_path).iter_commits(
f"{range_start}..{range_end}"
)
return []
commits = commit_stream_buffer.getvalue().splitlines()
]
raw_reviewers = []
for commit_sha in commits:

View File

@@ -9,4 +9,5 @@
##
edk2-pytool-library==0.*
GitPython==3.*
requests==2.*