auto approval

This commit is contained in:
mrT23
2024-02-06 08:31:36 +02:00
parent a126ef64fc
commit b190b1879e
8 changed files with 118 additions and 1 deletions

View File

@ -171,6 +171,11 @@ class GitProvider(ABC):
def get_latest_commit_url(self) -> str:
return ""
def auto_approve(self) -> bool:
return False
def get_main_pr_language(languages, files) -> str:
"""
Get the main language of the commit. Return an empty string if cannot determine.
@ -239,7 +244,6 @@ def get_main_pr_language(languages, files) -> str:
return main_language_str
class IncrementalPR:
def __init__(self, is_incremental: bool = False):
self.is_incremental = is_incremental

View File

@ -643,3 +643,13 @@ class GithubProvider(GitProvider):
return pr_id
except:
return ""
def auto_approve(self) -> bool:
try:
res = self.pr.create_review(event="APPROVE")
if res.state == "APPROVED":
return True
return False
except Exception as e:
get_logger().exception(f"Failed to auto-approve, error: {e}")
return False