mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 04:10:49 +08:00
bitbucket
This commit is contained in:
@ -282,7 +282,7 @@ def find_line_number_of_relevant_line_in_file(diff_files: List[FilePatchInfo],
|
|||||||
r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@[ ]?(.*)")
|
r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@[ ]?(.*)")
|
||||||
|
|
||||||
for file in diff_files:
|
for file in diff_files:
|
||||||
if file.filename.strip() == relevant_file:
|
if file.filename and (file.filename.strip() == relevant_file):
|
||||||
patch = file.patch
|
patch = file.patch
|
||||||
patch_lines = patch.splitlines()
|
patch_lines = patch.splitlines()
|
||||||
|
|
||||||
|
@ -153,18 +153,29 @@ class BitbucketProvider(GitProvider):
|
|||||||
self.diff_files = diff_files
|
self.diff_files = diff_files
|
||||||
return diff_files
|
return diff_files
|
||||||
|
|
||||||
|
def get_latest_commit_url(self):
|
||||||
|
return self.pr.data['source']['commit']['links']['html']['href']
|
||||||
|
|
||||||
|
def get_comment_url(self, comment):
|
||||||
|
return comment.data['links']['html']['href']
|
||||||
|
|
||||||
def publish_persistent_comment(self, pr_comment: str, initial_header: str, update_header: bool = True):
|
def publish_persistent_comment(self, pr_comment: str, initial_header: str, update_header: bool = True):
|
||||||
try:
|
try:
|
||||||
for comment in self.pr.comments():
|
for comment in self.pr.comments():
|
||||||
body = comment.raw
|
body = comment.raw
|
||||||
if initial_header in body:
|
if initial_header in body:
|
||||||
|
latest_commit_url = self.get_latest_commit_url()
|
||||||
|
comment_url = self.get_comment_url(comment)
|
||||||
if update_header:
|
if update_header:
|
||||||
updated_header = f"{initial_header}\n\n ### (updated)\n"
|
updated_header = f"{initial_header}\n\n### (review updated until commit {latest_commit_url})\n"
|
||||||
pr_comment_updated = pr_comment.replace(initial_header, updated_header)
|
pr_comment_updated = pr_comment.replace(initial_header, updated_header)
|
||||||
else:
|
else:
|
||||||
pr_comment_updated = pr_comment
|
pr_comment_updated = pr_comment
|
||||||
|
get_logger().info(f"Persistent mode- updating comment {comment_url} to latest review message")
|
||||||
d = {"content": {"raw": pr_comment_updated}}
|
d = {"content": {"raw": pr_comment_updated}}
|
||||||
response = comment._update_data(comment.put(None, data=d))
|
response = comment._update_data(comment.put(None, data=d))
|
||||||
|
self.publish_comment(
|
||||||
|
f"**[Persistent review]({comment_url})** updated to latest commit {latest_commit_url}")
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
get_logger().exception(f"Failed to update persistent review, error: {e}")
|
get_logger().exception(f"Failed to update persistent review, error: {e}")
|
||||||
|
Reference in New Issue
Block a user