Merge pull request #1859 from alessio-locatelli/respect_publish_output_no_suggestions_by_reviewer

feat: support 'publish_output_no_suggestions' by 'pr_reviewer'
This commit is contained in:
Tal
2025-06-13 19:42:32 +03:00
committed by GitHub
2 changed files with 22 additions and 14 deletions

View File

@ -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

View File

@ -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,