Implement Automatic Review Configuration for GitHub app

This commit is contained in:
Tim Perkins
2023-08-16 16:17:00 -04:00
parent dee1f168f8
commit 631fb93b28
4 changed files with 15 additions and 4 deletions

View File

@ -23,7 +23,7 @@ class PRReviewer:
"""
The PRReviewer class is responsible for reviewing a pull request and generating feedback using an AI model.
"""
def __init__(self, pr_url: str, is_answer: bool = False, args: list = None):
def __init__(self, pr_url: str, is_answer: bool = False, is_auto: bool = False, args: list = None):
"""
Initialize the PRReviewer object with the necessary attributes and objects to review a pull request.
@ -40,6 +40,7 @@ class PRReviewer:
)
self.pr_url = pr_url
self.is_answer = is_answer
self.is_auto = is_auto
if self.is_answer and not self.git_provider.is_supported("get_issue_comments"):
raise Exception(f"Answer mode is not supported for {get_settings().config.git_provider} for now")
@ -93,8 +94,12 @@ class PRReviewer:
"""
Review the pull request and generate feedback.
"""
logging.info('Reviewing PR...')
if self.is_auto and not get_settings().pr_reviewer.automatic_review:
logging.info(f'Automatic review is disabled {self.pr_url}')
return None
logging.info(f'Reviewing PR: {self.pr_url} ...')
if get_settings().config.publish_output:
self.git_provider.publish_comment("Preparing review...", is_temporary=True)