mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 11:50:37 +08:00
Remove 'bitbucket' explicit dependency anywhere that's not in bitbucket_provider.py
This commit is contained in:
@ -20,7 +20,7 @@ def get_setting(key: str) -> Any:
|
|||||||
except Exception:
|
except Exception:
|
||||||
return global_settings.get(key, None)
|
return global_settings.get(key, None)
|
||||||
|
|
||||||
def convert_to_markdown(output_data: dict) -> str:
|
def convert_to_markdown(output_data: dict, gfm_supported: bool) -> str:
|
||||||
"""
|
"""
|
||||||
Convert a dictionary of data into markdown format.
|
Convert a dictionary of data into markdown format.
|
||||||
Args:
|
Args:
|
||||||
@ -49,11 +49,14 @@ def convert_to_markdown(output_data: dict) -> str:
|
|||||||
continue
|
continue
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
markdown_text += f"## {key}\n\n"
|
markdown_text += f"## {key}\n\n"
|
||||||
markdown_text += convert_to_markdown(value)
|
markdown_text += convert_to_markdown(value, gfm_supported)
|
||||||
elif isinstance(value, list):
|
elif isinstance(value, list):
|
||||||
emoji = emojis.get(key, "")
|
emoji = emojis.get(key, "")
|
||||||
if key.lower() == 'code feedback':
|
if key.lower() == 'code feedback':
|
||||||
markdown_text += f"\n\n- **<details><summary> { emoji } Code feedback:**</summary>\n\n"
|
if gfm_supported:
|
||||||
|
markdown_text += f"\n\n- **<details><summary> { emoji } Code feedback:**</summary>\n\n"
|
||||||
|
else:
|
||||||
|
markdown_text += f"\n\n- **{emoji} Code feedback:**\n\n"
|
||||||
else:
|
else:
|
||||||
markdown_text += f"- {emoji} **{key}:**\n\n"
|
markdown_text += f"- {emoji} **{key}:**\n\n"
|
||||||
for item in value:
|
for item in value:
|
||||||
@ -62,7 +65,10 @@ def convert_to_markdown(output_data: dict) -> str:
|
|||||||
elif item:
|
elif item:
|
||||||
markdown_text += f" - {item}\n"
|
markdown_text += f" - {item}\n"
|
||||||
if key.lower() == 'code feedback':
|
if key.lower() == 'code feedback':
|
||||||
markdown_text += "</details>\n\n"
|
if gfm_supported:
|
||||||
|
markdown_text += "</details>\n\n"
|
||||||
|
else:
|
||||||
|
markdown_text += "\n\n"
|
||||||
elif value != 'n/a':
|
elif value != 'n/a':
|
||||||
emoji = emojis.get(key, "")
|
emoji = emojis.get(key, "")
|
||||||
markdown_text += f"- {emoji} **{key}:** {value}\n"
|
markdown_text += f"- {emoji} **{key}:** {value}\n"
|
||||||
|
@ -38,7 +38,8 @@ class AzureDevopsProvider:
|
|||||||
self.set_pr(pr_url)
|
self.set_pr(pr_url)
|
||||||
|
|
||||||
def is_supported(self, capability: str) -> bool:
|
def is_supported(self, capability: str) -> bool:
|
||||||
if capability in ['get_issue_comments', 'create_inline_comment', 'publish_inline_comments', 'get_labels', 'remove_initial_comment']:
|
if capability in ['get_issue_comments', 'create_inline_comment', 'publish_inline_comments', 'get_labels',
|
||||||
|
'remove_initial_comment', 'gfm_markdown']:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -101,8 +101,7 @@ class BitbucketProvider(GitProvider):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def is_supported(self, capability: str) -> bool:
|
def is_supported(self, capability: str) -> bool:
|
||||||
if capability in ['get_issue_comments', 'publish_inline_comments', 'get_labels']:
|
if capability in ['get_issue_comments', 'publish_inline_comments', 'get_labels', 'gfm_markdown']:
|
||||||
|
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -180,11 +179,6 @@ class BitbucketProvider(GitProvider):
|
|||||||
for comment in comments:
|
for comment in comments:
|
||||||
self.publish_inline_comment(comment['body'], comment['start_line'], comment['path'])
|
self.publish_inline_comment(comment['body'], comment['start_line'], comment['path'])
|
||||||
|
|
||||||
def publish_bitbucket_inline_comments(self, comments: list[dict]):
|
|
||||||
for comment in comments:
|
|
||||||
self.publish_inline_comment(comment['body'],comment['position'], comment['path'])
|
|
||||||
|
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
return self.pr.title
|
return self.pr.title
|
||||||
|
|
||||||
|
@ -54,11 +54,16 @@ class CodeCommitClient:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.boto_client = None
|
self.boto_client = None
|
||||||
|
|
||||||
|
def is_supported(self, capability: str) -> bool:
|
||||||
|
if capability in ["gfm_markdown"]:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def _connect_boto_client(self):
|
def _connect_boto_client(self):
|
||||||
try:
|
try:
|
||||||
self.boto_client = boto3.client("codecommit")
|
self.boto_client = boto3.client("codecommit")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(f"Failed to connect to AWS CodeCommit: {e}")
|
raise ValueError(f"Failed to connect to AWS CodeCommit: {e}") from e
|
||||||
|
|
||||||
def get_differences(self, repo_name: int, destination_commit: str, source_commit: str):
|
def get_differences(self, repo_name: int, destination_commit: str, source_commit: str):
|
||||||
"""
|
"""
|
||||||
|
@ -74,6 +74,7 @@ class CodeCommitProvider(GitProvider):
|
|||||||
"create_inline_comment",
|
"create_inline_comment",
|
||||||
"publish_inline_comments",
|
"publish_inline_comments",
|
||||||
"get_labels",
|
"get_labels",
|
||||||
|
"gfm_markdown"
|
||||||
]:
|
]:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -304,7 +304,8 @@ class GerritProvider(GitProvider):
|
|||||||
# 'get_issue_comments',
|
# 'get_issue_comments',
|
||||||
'create_inline_comment',
|
'create_inline_comment',
|
||||||
'publish_inline_comments',
|
'publish_inline_comments',
|
||||||
'get_labels'
|
'get_labels',
|
||||||
|
'gfm_markdown'
|
||||||
]:
|
]:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -43,7 +43,7 @@ class GitLabProvider(GitProvider):
|
|||||||
self.incremental = incremental
|
self.incremental = incremental
|
||||||
|
|
||||||
def is_supported(self, capability: str) -> bool:
|
def is_supported(self, capability: str) -> bool:
|
||||||
if capability in ['get_issue_comments', 'create_inline_comment', 'publish_inline_comments']:
|
if capability in ['get_issue_comments', 'create_inline_comment', 'publish_inline_comments', 'gfm_markdown']:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -56,7 +56,8 @@ class LocalGitProvider(GitProvider):
|
|||||||
raise KeyError(f'Branch: {self.target_branch_name} does not exist')
|
raise KeyError(f'Branch: {self.target_branch_name} does not exist')
|
||||||
|
|
||||||
def is_supported(self, capability: str) -> bool:
|
def is_supported(self, capability: str) -> bool:
|
||||||
if capability in ['get_issue_comments', 'create_inline_comment', 'publish_inline_comments', 'get_labels']:
|
if capability in ['get_issue_comments', 'create_inline_comment', 'publish_inline_comments', 'get_labels',
|
||||||
|
'gfm_markdown']:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -43,5 +43,10 @@ webhook_secret = "<WEBHOOK SECRET>" # Optional, may be commented out.
|
|||||||
personal_access_token = ""
|
personal_access_token = ""
|
||||||
|
|
||||||
[bitbucket]
|
[bitbucket]
|
||||||
# Bitbucket personal bearer token
|
# For Bitbucket personal/repository bearer token
|
||||||
bearer_token = ""
|
bearer_token = ""
|
||||||
|
|
||||||
|
# For Bitbucket app
|
||||||
|
app_key = ""
|
||||||
|
base_url = ""
|
||||||
|
|
||||||
|
@ -75,17 +75,12 @@ class PRDescription:
|
|||||||
if get_settings().pr_description.publish_description_as_comment:
|
if get_settings().pr_description.publish_description_as_comment:
|
||||||
self.git_provider.publish_comment(pr_body)
|
self.git_provider.publish_comment(pr_body)
|
||||||
else:
|
else:
|
||||||
# bitbucket does not support publishing PR labels yet
|
self.git_provider.publish_description(pr_title, pr_body)
|
||||||
if get_settings().config.git_provider == 'bitbucket':
|
if self.git_provider.is_supported("get_labels"):
|
||||||
self.git_provider.publish_description(pr_title, description)
|
current_labels = self.git_provider.get_labels()
|
||||||
return
|
if current_labels is None:
|
||||||
else:
|
current_labels = []
|
||||||
self.git_provider.publish_description(pr_title, pr_body)
|
self.git_provider.publish_labels(pr_types + current_labels)
|
||||||
if self.git_provider.is_supported("get_labels"):
|
|
||||||
current_labels = self.git_provider.get_labels()
|
|
||||||
if current_labels is None:
|
|
||||||
current_labels = []
|
|
||||||
self.git_provider.publish_labels(pr_types + current_labels)
|
|
||||||
self.git_provider.remove_initial_comment()
|
self.git_provider.remove_initial_comment()
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
@ -214,7 +214,7 @@ class PRReviewer:
|
|||||||
"⏮️ Review for commits since previous PR-Agent review": f"Starting from commit {last_commit_url}"}})
|
"⏮️ Review for commits since previous PR-Agent review": f"Starting from commit {last_commit_url}"}})
|
||||||
data.move_to_end('Incremental PR Review', last=False)
|
data.move_to_end('Incremental PR Review', last=False)
|
||||||
|
|
||||||
markdown_text = convert_to_markdown(data)
|
markdown_text = convert_to_markdown(data, self.git_provider.is_supported("gfm_markdown"))
|
||||||
user = self.git_provider.get_user_id()
|
user = self.git_provider.get_user_id()
|
||||||
|
|
||||||
# Add help text if not in CLI mode
|
# Add help text if not in CLI mode
|
||||||
@ -266,9 +266,6 @@ class PRReviewer:
|
|||||||
self.git_provider.publish_inline_comment(content, relevant_file, relevant_line_in_file)
|
self.git_provider.publish_inline_comment(content, relevant_file, relevant_line_in_file)
|
||||||
|
|
||||||
if comments:
|
if comments:
|
||||||
if get_settings().config.git_provider == 'bitbucket':
|
|
||||||
self.git_provider.publish_bitbucket_inline_comments(comments)
|
|
||||||
else:
|
|
||||||
self.git_provider.publish_inline_comments(comments)
|
self.git_provider.publish_inline_comments(comments)
|
||||||
|
|
||||||
def _get_user_answers(self) -> Tuple[str, str]:
|
def _get_user_answers(self) -> Tuple[str, str]:
|
||||||
|
Reference in New Issue
Block a user