mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 13:20:39 +08:00
fix publish description for bitbucket
This commit is contained in:
@ -36,9 +36,8 @@ class BitbucketProvider(GitProvider):
|
|||||||
self.incremental = incremental
|
self.incremental = incremental
|
||||||
if pr_url:
|
if pr_url:
|
||||||
self.set_pr(pr_url)
|
self.set_pr(pr_url)
|
||||||
self.bitbucket_comment_api_url = self.pr._BitbucketBase__data["links"][
|
self.bitbucket_comment_api_url = self.pr._BitbucketBase__data["links"]["comments"]["href"]
|
||||||
"comments"
|
self.bitbucket_pull_request_api_url = self.pr._BitbucketBase__data["links"]['self']['href']
|
||||||
]["href"]
|
|
||||||
|
|
||||||
def get_repo_settings(self):
|
def get_repo_settings(self):
|
||||||
try:
|
try:
|
||||||
@ -253,8 +252,15 @@ class BitbucketProvider(GitProvider):
|
|||||||
return "" # not implemented yet
|
return "" # not implemented yet
|
||||||
|
|
||||||
# bitbucket does not support labels
|
# bitbucket does not support labels
|
||||||
def publish_description(self, pr_title: str, pr_body: str):
|
def publish_description(self, pr_title: str, description: str):
|
||||||
pass
|
payload = json.dumps({
|
||||||
|
"description": description,
|
||||||
|
"title": pr_title
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
response = requests.request("PUT", self.bitbucket_pull_request_api_url, headers=self.headers, data=payload)
|
||||||
|
return response
|
||||||
|
|
||||||
# bitbucket does not support labels
|
# bitbucket does not support labels
|
||||||
def publish_labels(self, pr_types: list):
|
def publish_labels(self, pr_types: list):
|
||||||
|
@ -68,7 +68,7 @@ class PRDescription:
|
|||||||
await retry_with_fallback_models(self._prepare_prediction)
|
await retry_with_fallback_models(self._prepare_prediction)
|
||||||
|
|
||||||
logging.info('Preparing answer...')
|
logging.info('Preparing answer...')
|
||||||
pr_title, pr_body, pr_types, markdown_text = self._prepare_pr_answer()
|
pr_title, pr_body, pr_types, markdown_text, description = self._prepare_pr_answer()
|
||||||
|
|
||||||
if get_settings().config.publish_output:
|
if get_settings().config.publish_output:
|
||||||
logging.info('Pushing answer...')
|
logging.info('Pushing answer...')
|
||||||
@ -77,6 +77,7 @@ class PRDescription:
|
|||||||
else:
|
else:
|
||||||
# bitbucket does not support publishing PR labels yet
|
# bitbucket does not support publishing PR labels yet
|
||||||
if get_settings().config.git_provider == 'bitbucket':
|
if get_settings().config.git_provider == 'bitbucket':
|
||||||
|
self.git_provider.publish_description(pr_title, description)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.git_provider.publish_description(pr_title, pr_body)
|
self.git_provider.publish_description(pr_title, pr_body)
|
||||||
@ -147,6 +148,7 @@ class PRDescription:
|
|||||||
- pr_body: a string containing the PR body in a markdown format.
|
- pr_body: a string containing the PR body in a markdown format.
|
||||||
- pr_types: a list of strings containing the PR types.
|
- pr_types: a list of strings containing the PR types.
|
||||||
- markdown_text: a string containing the AI prediction data in a markdown format. used for publishing a comment
|
- markdown_text: a string containing the AI prediction data in a markdown format. used for publishing a comment
|
||||||
|
- user_description: a string containing the user description
|
||||||
"""
|
"""
|
||||||
# Load the AI prediction data into a dictionary
|
# Load the AI prediction data into a dictionary
|
||||||
data = load_yaml(self.prediction.strip())
|
data = load_yaml(self.prediction.strip())
|
||||||
@ -193,8 +195,9 @@ class PRDescription:
|
|||||||
pr_body += "\n___\n"
|
pr_body += "\n___\n"
|
||||||
|
|
||||||
markdown_text = f"## Title\n\n{title}\n\n___\n{pr_body}"
|
markdown_text = f"## Title\n\n{title}\n\n___\n{pr_body}"
|
||||||
|
description = data['PR Description']
|
||||||
|
|
||||||
if get_settings().config.verbosity_level >= 2:
|
if get_settings().config.verbosity_level >= 2:
|
||||||
logging.info(f"title:\n{title}\n{pr_body}")
|
logging.info(f"title:\n{title}\n{pr_body}")
|
||||||
|
|
||||||
return title, pr_body, pr_types, markdown_text
|
return title, pr_body, pr_types, markdown_text, description
|
Reference in New Issue
Block a user