fixed bugs with incremental review

This commit is contained in:
mrT23
2024-02-22 18:03:00 +02:00
parent adc5709b29
commit 8b76eb1014
3 changed files with 10 additions and 20 deletions

View File

@ -34,8 +34,10 @@ class GithubProvider(GitProvider):
self.incremental = incremental
if pr_url and 'pull' in pr_url:
self.set_pr(pr_url)
self.pr_commits = self.pr.get_commits()
self.last_commit_id = list(self.pr_commits)[-1]
self.pr_commits = list(self.pr.get_commits())
if self.incremental.is_incremental:
self.get_incremental_commits()
self.last_commit_id = self.pr_commits[-1]
self.pr_url = self.get_pr_url() # pr_url for github actions can be as api.github.com, so we need to get the url from the pr object
else:
self.pr_commits = None
@ -49,8 +51,6 @@ class GithubProvider(GitProvider):
def set_pr(self, pr_url: str):
self.repo, self.pr_num = self._parse_pr_url(pr_url)
self.pr = self._get_pr()
if self.incremental.is_incremental:
self.get_incremental_commits()
def get_incremental_commits(self):
if not self.pr_commits:
@ -88,7 +88,7 @@ class GithubProvider(GitProvider):
self.comments = list(self.pr.get_issue_comments())
prefixes = []
if full:
prefixes.append("## PR Analysis")
prefixes.append("## PR Review")
if incremental:
prefixes.append("## Incremental PR Review")
for index in range(len(self.comments) - 1, -1, -1):

View File

@ -35,7 +35,6 @@ async def handle_github_webhooks(request: Request, response: Response):
body = await get_body(request)
get_logger().debug(f'Request body:\n{body}')
installation_id = body.get("installation", {}).get("id")
context["installation_id"] = installation_id
context["settings"] = copy.deepcopy(global_settings)
@ -209,15 +208,18 @@ async def handle_request(body: Dict[str, Any], event: str):
# handle comments on PRs
if action == 'created':
get_logger().info(f'Request body:\n{body}')
await handle_comments_on_pr(body, event, sender, action, log_context, agent)
# handle new PRs
elif event == 'pull_request' and action != 'synchronize':
get_logger().info(f'Request body:\n{body}')
await handle_new_pr_opened(body, event, sender, action, log_context, agent)
# handle pull_request event with synchronize action - "push trigger" for new commits
elif event == 'pull_request' and action == 'synchronize':
get_logger().info(f'Request body:\n{body}')
await handle_push_trigger_for_new_commits(body, event, sender, action, log_context, agent)
else:
get_logger().info("event or action does not require handling")
get_logger().info(f"event {event=} action {action=} does not require any handling")
return {}

View File

@ -150,19 +150,7 @@ push_trigger_pending_tasks_backlog = true
push_trigger_pending_tasks_ttl = 300
push_commands = [
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
"""/auto_review -i \
--pr_reviewer.require_focused_review=false \
--pr_reviewer.require_score_review=false \
--pr_reviewer.require_tests_review=false \
--pr_reviewer.require_estimate_effort_to_review=false \
--pr_reviewer.num_code_suggestions=0 \
--pr_reviewer.inline_code_comments=false \
--pr_reviewer.remove_previous_review_comment=true \
--pr_reviewer.require_all_thresholds_for_incremental_review=false \
--pr_reviewer.minimal_commits_for_incremental_review=5 \
--pr_reviewer.minimal_minutes_for_incremental_review=30 \
--pr_reviewer.extra_instructions='' \
"""
"/review --pr_reviewer.num_code_suggestions=0",
]
ignore_pr_title = []