mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 12:50:38 +08:00
rename + check github
This commit is contained in:
@ -38,7 +38,7 @@ class GithubProvider(GitProvider):
|
|||||||
self.set_pr(pr_url)
|
self.set_pr(pr_url)
|
||||||
self.pr_commits = list(self.pr.get_commits())
|
self.pr_commits = list(self.pr.get_commits())
|
||||||
if self.incremental.is_incremental:
|
if self.incremental.is_incremental:
|
||||||
self.file_set = dict()
|
self.unreviewed_files_set = dict()
|
||||||
self.get_incremental_commits()
|
self.get_incremental_commits()
|
||||||
self.last_commit_id = self.pr_commits[-1]
|
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
|
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
|
||||||
@ -68,7 +68,7 @@ class GithubProvider(GitProvider):
|
|||||||
if commit.commit.message.startswith(f"Merge branch '{self._get_repo().default_branch}'"):
|
if commit.commit.message.startswith(f"Merge branch '{self._get_repo().default_branch}'"):
|
||||||
get_logger().info(f"Skipping merge commit {commit.commit.message}")
|
get_logger().info(f"Skipping merge commit {commit.commit.message}")
|
||||||
continue
|
continue
|
||||||
self.file_set.update({file.filename: file for file in commit.files})
|
self.unreviewed_files_set.update({file.filename: file for file in commit.files})
|
||||||
else:
|
else:
|
||||||
raise ValueError("No previous review found")
|
raise ValueError("No previous review found")
|
||||||
|
|
||||||
@ -99,8 +99,8 @@ class GithubProvider(GitProvider):
|
|||||||
return self.comments[index]
|
return self.comments[index]
|
||||||
|
|
||||||
def get_files(self):
|
def get_files(self):
|
||||||
if self.incremental.is_incremental and self.file_set:
|
if self.incremental.is_incremental and self.unreviewed_files_set:
|
||||||
return self.file_set.values()
|
return self.unreviewed_files_set.values()
|
||||||
try:
|
try:
|
||||||
git_files = context.get("git_files", None)
|
git_files = context.get("git_files", None)
|
||||||
if git_files:
|
if git_files:
|
||||||
@ -146,10 +146,10 @@ class GithubProvider(GitProvider):
|
|||||||
new_file_content_str = self._get_pr_file_content(file, self.pr.head.sha) # communication with GitHub
|
new_file_content_str = self._get_pr_file_content(file, self.pr.head.sha) # communication with GitHub
|
||||||
patch = file.patch
|
patch = file.patch
|
||||||
|
|
||||||
if self.incremental.is_incremental and self.file_set:
|
if self.incremental.is_incremental and self.unreviewed_files_set:
|
||||||
original_file_content_str = self._get_pr_file_content(file, self.incremental.last_seen_commit_sha)
|
original_file_content_str = self._get_pr_file_content(file, self.incremental.last_seen_commit_sha)
|
||||||
patch = load_large_diff(file.filename, new_file_content_str, original_file_content_str)
|
patch = load_large_diff(file.filename, new_file_content_str, original_file_content_str)
|
||||||
self.file_set[file.filename] = patch
|
self.unreviewed_files_set[file.filename] = patch
|
||||||
else:
|
else:
|
||||||
original_file_content_str = self._get_pr_file_content(file, self.pr.base.sha)
|
original_file_content_str = self._get_pr_file_content(file, self.pr.base.sha)
|
||||||
if not patch:
|
if not patch:
|
||||||
|
@ -108,14 +108,14 @@ class PRReviewer:
|
|||||||
'config': dict(get_settings().config)}
|
'config': dict(get_settings().config)}
|
||||||
get_logger().debug("Relevant configs", artifacts=relevant_configs)
|
get_logger().debug("Relevant configs", artifacts=relevant_configs)
|
||||||
|
|
||||||
if self.incremental.is_incremental and hasattr(self.git_provider, "file_set") and not self.git_provider.file_set:
|
if self.incremental.is_incremental and hasattr(self.git_provider, "file_set") and not self.git_provider.unreviewed_files_set:
|
||||||
get_logger().info(f"Incremental review is enabled for {self.pr_url} but there are no new files")
|
get_logger().info(f"Incremental review is enabled for {self.pr_url} but there are no new files")
|
||||||
previous_review_url = ""
|
previous_review_url = ""
|
||||||
if hasattr(self.git_provider, "previous_review"):
|
if hasattr(self.git_provider, "previous_review"):
|
||||||
previous_review_url = self.git_provider.previous_review.html_url
|
previous_review_url = self.git_provider.previous_review.html_url
|
||||||
if get_settings().config.publish_output:
|
if get_settings().config.publish_output:
|
||||||
self.git_provider.publish_comment(f"Incremental Review Skipped\n"
|
self.git_provider.publish_comment(f"Incremental Review Skipped\n"
|
||||||
f"No files were changed since the [previous PR Review]({previous_review_url})", is_temporary=True)
|
f"No files were changed since the [previous PR Review]({previous_review_url})")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if get_settings().config.publish_output:
|
if get_settings().config.publish_output:
|
||||||
@ -324,6 +324,10 @@ class PRReviewer:
|
|||||||
if self.is_auto and not self.incremental.first_new_commit_sha:
|
if self.is_auto and not self.incremental.first_new_commit_sha:
|
||||||
get_logger().info(f"Incremental review is enabled for {self.pr_url} but there are no new commits")
|
get_logger().info(f"Incremental review is enabled for {self.pr_url} but there are no new commits")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if not hasattr(self.git_provider, "get_incremental_commits"):
|
||||||
|
get_logger().info(f"Incremental review is not supported for {get_settings().config.git_provider}")
|
||||||
|
return False
|
||||||
# checking if there are enough commits to start the review
|
# checking if there are enough commits to start the review
|
||||||
num_new_commits = len(self.incremental.commits_range)
|
num_new_commits = len(self.incremental.commits_range)
|
||||||
num_commits_threshold = get_settings().pr_reviewer.minimal_commits_for_incremental_review
|
num_commits_threshold = get_settings().pr_reviewer.minimal_commits_for_incremental_review
|
||||||
|
Reference in New Issue
Block a user