mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 13:20:39 +08:00
publish_persistent_comment
This commit is contained in:
@ -153,10 +153,7 @@ class BitbucketProvider(GitProvider):
|
|||||||
self.diff_files = diff_files
|
self.diff_files = diff_files
|
||||||
return diff_files
|
return diff_files
|
||||||
|
|
||||||
|
def publish_persistent_comment(self, pr_comment: str, initial_text: str, updated_text: str):
|
||||||
def publish_persistent_comment(self, pr_comment: str,
|
|
||||||
initial_text="## PR Analysis",
|
|
||||||
updated_text="## PR Analysis (updated)"):
|
|
||||||
try:
|
try:
|
||||||
for comment in self.pr.comments():
|
for comment in self.pr.comments():
|
||||||
body = comment.raw
|
body = comment.raw
|
||||||
|
@ -44,7 +44,7 @@ class GitProvider(ABC):
|
|||||||
def publish_comment(self, pr_comment: str, is_temporary: bool = False):
|
def publish_comment(self, pr_comment: str, is_temporary: bool = False):
|
||||||
pass
|
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)
|
self.publish_comment(pr_comment)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
@ -154,9 +154,7 @@ class GithubProvider(GitProvider):
|
|||||||
def publish_description(self, pr_title: str, pr_body: str):
|
def publish_description(self, pr_title: str, pr_body: str):
|
||||||
self.pr.edit(title=pr_title, body=pr_body)
|
self.pr.edit(title=pr_title, body=pr_body)
|
||||||
|
|
||||||
def publish_persistent_comment(self, pr_comment: str,
|
def publish_persistent_comment(self, pr_comment: str, initial_text: str, updated_text: str):
|
||||||
initial_text="## PR Analysis",
|
|
||||||
updated_text="## PR Analysis (updated)"):
|
|
||||||
prev_comments = list(self.pr.get_issue_comments())
|
prev_comments = list(self.pr.get_issue_comments())
|
||||||
for comment in prev_comments:
|
for comment in prev_comments:
|
||||||
body = comment.body
|
body = comment.body
|
||||||
|
@ -136,9 +136,7 @@ class GitLabProvider(GitProvider):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
get_logger().exception(f"Could not update merge request {self.id_mr} description: {e}")
|
get_logger().exception(f"Could not update merge request {self.id_mr} description: {e}")
|
||||||
|
|
||||||
def publish_persistent_comment(self, pr_comment: str,
|
def publish_persistent_comment(self, pr_comment: str, initial_text: str, updated_text: str):
|
||||||
initial_text="## PR Analysis",
|
|
||||||
updated_text="## PR Analysis (updated)"):
|
|
||||||
try:
|
try:
|
||||||
for comment in self.mr.notes.list(get_all=True)[::-1]:
|
for comment in self.mr.notes.list(get_all=True)[::-1]:
|
||||||
if comment.body.startswith(initial_text):
|
if comment.body.startswith(initial_text):
|
||||||
|
@ -120,7 +120,9 @@ class PRReviewer:
|
|||||||
|
|
||||||
# publish the review
|
# publish the review
|
||||||
if get_settings().pr_reviewer.persistent_comment and not self.incremental.is_incremental:
|
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:
|
else:
|
||||||
self.git_provider.publish_comment(pr_comment)
|
self.git_provider.publish_comment(pr_comment)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user