Skip to content

Commit be18152

Browse files
committed
refresh
1 parent 7fc4140 commit be18152

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pr_agent/tools/pr_code_suggestions.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,10 @@ async def run(self):
143143
initial_header="## PR Code Suggestions ✨",
144144
update_header=True,
145145
name="suggestions",
146-
final_update_message = final_update_message,
147-
max_previous_comments = get_settings().pr_code_suggestions.max_history_len,
148-
progress_response = self.progress_response)
146+
final_update_message=final_update_message,
147+
max_previous_comments=get_settings().pr_code_suggestions.max_history_len,
148+
progress_response=self.progress_response)
149149
else:
150-
151150
if self.progress_response:
152151
self.git_provider.edit_comment(self.progress_response, body=pr_body)
153152
else:
@@ -232,6 +231,7 @@ def publish_persistent_comment_with_history(self, pr_comment: str,
232231
# Add to the prev_suggestions section
233232
last_prev_table = f"\n<details><summary>{tick}{name.capitalize()}{up_to_commit_txt}</summary>\n<br>{latest_table}\n\n</details>"
234233
prev_suggestion_table = last_prev_table + "\n" + prev_suggestion_table
234+
235235
new_suggestion_table = pr_comment.replace(initial_header, "").strip()
236236

237237
pr_comment_updated = f"{initial_header}\n"
@@ -243,19 +243,20 @@ def publish_persistent_comment_with_history(self, pr_comment: str,
243243

244244
get_logger().info(f"Persistent mode - updating comment {comment_url} to latest {name} message")
245245
if progress_response: # publish to 'progress_response' comment, because it refreshes immediately
246-
comment.delete()
247246
self.git_provider.edit_comment(progress_response, pr_comment_updated)
247+
comment.delete()
248248
else:
249249
self.git_provider.edit_comment(comment, pr_comment_updated)
250250
return
251251
except Exception as e:
252252
get_logger().exception(f"Failed to update persistent review, error: {e}")
253253
pass
254254

255+
# if we are here, we did not find a previous comment to update
255256
body = pr_comment.replace(initial_header, "").strip()
256257
pr_comment = f"{initial_header}\n\n{latest_commit_html_comment}\n\n{body}\n\n"
257-
if found_comment is not None:
258-
self.git_provider.edit_comment(found_comment, pr_comment)
258+
if progress_response:
259+
self.git_provider.edit_comment(progress_response, pr_comment)
259260
else:
260261
self.git_provider.publish_comment(pr_comment)
261262

0 commit comments

Comments
 (0)