mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 20:00:41 +08:00
refactor: simplify IF/ELSE block
This commit is contained in:
@ -158,32 +158,30 @@ class PRReviewer:
|
||||
pr_review = self._prepare_pr_review()
|
||||
get_logger().debug(f"PR output", artifact=pr_review)
|
||||
|
||||
if get_settings().config.publish_output:
|
||||
# publish the review
|
||||
if get_settings().pr_reviewer.persistent_comment and not self.incremental.is_incremental:
|
||||
if self._should_publish_review(pr_review):
|
||||
final_update_message = get_settings().pr_reviewer.final_update_message
|
||||
self.git_provider.publish_persistent_comment(pr_review,
|
||||
initial_header=f"{PRReviewHeader.REGULAR.value} 🔍",
|
||||
update_header=True,
|
||||
final_update_message=final_update_message, )
|
||||
else:
|
||||
get_logger().info("Review output is not published: no major issues detected.")
|
||||
else:
|
||||
if self._should_publish_review(pr_review):
|
||||
self.git_provider.publish_comment(pr_review)
|
||||
else:
|
||||
get_logger().info("Review output is not published: no major issues detected.")
|
||||
|
||||
self.git_provider.remove_initial_comment()
|
||||
else:
|
||||
get_logger().info("Review output is not published")
|
||||
should_publish = get_settings().config.publish_output and self._should_publish_review_no_suggestions(pr_review)
|
||||
if not should_publish:
|
||||
reason = "Review output is not published"
|
||||
if get_settings().config.publish_output:
|
||||
reason += ": no major issues detected."
|
||||
get_logger().info(reason)
|
||||
get_settings().data = {"artifact": pr_review}
|
||||
return
|
||||
|
||||
# publish the review
|
||||
if get_settings().pr_reviewer.persistent_comment and not self.incremental.is_incremental:
|
||||
final_update_message = get_settings().pr_reviewer.final_update_message
|
||||
self.git_provider.publish_persistent_comment(pr_review,
|
||||
initial_header=f"{PRReviewHeader.REGULAR.value} 🔍",
|
||||
update_header=True,
|
||||
final_update_message=final_update_message, )
|
||||
else:
|
||||
self.git_provider.publish_comment(pr_review)
|
||||
|
||||
self.git_provider.remove_initial_comment()
|
||||
except Exception as e:
|
||||
get_logger().error(f"Failed to review PR: {e}")
|
||||
|
||||
def _should_publish_review(self, pr_review: str) -> bool:
|
||||
def _should_publish_review_no_suggestions(self, pr_review: str) -> bool:
|
||||
return get_settings().pr_reviewer.get('publish_output_no_suggestions', True) or "No major issues detected" not in pr_review
|
||||
|
||||
async def _prepare_prediction(self, model: str) -> None:
|
||||
|
Reference in New Issue
Block a user