diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index a93ea1f2..ea651731 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -80,6 +80,7 @@ require_can_be_split_review=false require_security_review=true require_ticket_analysis_review=true # general options +publish_output_no_suggestions=true # Set to "false" if you only need the reviewer's remarks (not labels, not "security audit", etc.) and want to avoid noisy "No major issues detected" comments. persistent_comment=true extra_instructions = "" num_max_findings = 3 diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 714ee867..4c1fb4d7 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -158,25 +158,32 @@ 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: - 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() - 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_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: self.patches_diff = get_pr_diff(self.git_provider, self.token_handler,