From 737792d83c50f788e4c8bcd70d97833f371d284f Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 9 Nov 2023 15:24:55 +0200 Subject: [PATCH] publish_persistent_comment --- pr_agent/git_providers/bitbucket_provider.py | 5 +---- pr_agent/git_providers/git_provider.py | 2 +- pr_agent/git_providers/github_provider.py | 4 +--- pr_agent/git_providers/gitlab_provider.py | 4 +--- pr_agent/tools/pr_reviewer.py | 4 +++- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pr_agent/git_providers/bitbucket_provider.py b/pr_agent/git_providers/bitbucket_provider.py index 8c9016c9..47f2b32a 100644 --- a/pr_agent/git_providers/bitbucket_provider.py +++ b/pr_agent/git_providers/bitbucket_provider.py @@ -153,10 +153,7 @@ class BitbucketProvider(GitProvider): self.diff_files = diff_files return diff_files - - def publish_persistent_comment(self, pr_comment: str, - initial_text="## PR Analysis", - updated_text="## PR Analysis (updated)"): + def publish_persistent_comment(self, pr_comment: str, initial_text: str, updated_text: str): try: for comment in self.pr.comments(): body = comment.raw diff --git a/pr_agent/git_providers/git_provider.py b/pr_agent/git_providers/git_provider.py index 1f9b3e41..1e18d86e 100644 --- a/pr_agent/git_providers/git_provider.py +++ b/pr_agent/git_providers/git_provider.py @@ -44,7 +44,7 @@ class GitProvider(ABC): def publish_comment(self, pr_comment: str, is_temporary: bool = False): pass - def publish_persistent_comment(self, pr_comment: str): + def publish_persistent_comment(self, pr_comment: str, initial_text: str, updated_text: str): self.publish_comment(pr_comment) @abstractmethod diff --git a/pr_agent/git_providers/github_provider.py b/pr_agent/git_providers/github_provider.py index f0871cb1..c0b9cc11 100644 --- a/pr_agent/git_providers/github_provider.py +++ b/pr_agent/git_providers/github_provider.py @@ -154,9 +154,7 @@ class GithubProvider(GitProvider): def publish_description(self, pr_title: str, pr_body: str): self.pr.edit(title=pr_title, body=pr_body) - def publish_persistent_comment(self, pr_comment: str, - initial_text="## PR Analysis", - updated_text="## PR Analysis (updated)"): + def publish_persistent_comment(self, pr_comment: str, initial_text: str, updated_text: str): prev_comments = list(self.pr.get_issue_comments()) for comment in prev_comments: body = comment.body diff --git a/pr_agent/git_providers/gitlab_provider.py b/pr_agent/git_providers/gitlab_provider.py index e687622e..396483a5 100644 --- a/pr_agent/git_providers/gitlab_provider.py +++ b/pr_agent/git_providers/gitlab_provider.py @@ -136,9 +136,7 @@ class GitLabProvider(GitProvider): except Exception as e: get_logger().exception(f"Could not update merge request {self.id_mr} description: {e}") - def publish_persistent_comment(self, pr_comment: str, - initial_text="## PR Analysis", - updated_text="## PR Analysis (updated)"): + def publish_persistent_comment(self, pr_comment: str, initial_text: str, updated_text: str): try: for comment in self.mr.notes.list(get_all=True)[::-1]: if comment.body.startswith(initial_text): diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 2106de7b..5b8e5472 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -120,7 +120,9 @@ class PRReviewer: # publish the review if get_settings().pr_reviewer.persistent_comment and not self.incremental.is_incremental: - self.git_provider.publish_persistent_comment(pr_comment) + self.git_provider.publish_persistent_comment(pr_comment, + initial_text="## PR Analysis", + updated_text="## PR Analysis (updated)") else: self.git_provider.publish_comment(pr_comment)