-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bitbucket publish description #302
Fix bitbucket publish description #302
Conversation
…_bitbucket_publish_description
…_bitbucket_publish_description
…_bitbucket_publish_description
…_bitbucket_publish_description
/improve --pr_code_suggestions.extra_instructions="focus on improving the robustness of the changes and managing with edge cases" |
response = requests.request("PUT", self.bitbucket_pull_request_api_url, headers=self.headers, data=payload) | ||
return response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Handle the case where the request to the bitbucket_pull_request_api_url fails.
response = requests.request("PUT", self.bitbucket_pull_request_api_url, headers=self.headers, data=payload) | |
return response | |
response = requests.request("PUT", self.bitbucket_pull_request_api_url, headers=self.headers, data=payload) | |
if response.status_code != 200: | |
logging.error('Failed to update PR description: %s', response.text) | |
return response |
pattern = r"## PR Description:\s*(.*?)\n___" | ||
match = re.search(pattern, pr_body, re.DOTALL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Handle the case where pr_body is None or empty, to avoid errors when trying to apply the regex.
pattern = r"## PR Description:\s*(.*?)\n___" | |
match = re.search(pattern, pr_body, re.DOTALL) | |
description = "" | |
if pr_body: | |
pattern = r"## PR Description:\s*(.*?)\n___" | |
match = re.search(pattern, pr_body, re.DOTALL) | |
if match: | |
pr_description = match.group(1).strip() | |
if pr_description: | |
description = pr_description |
payload = json.dumps({ | ||
"description": description, | ||
"title": pr_title | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add a check to ensure that pr_title is not None or empty before using it in the payload.
payload = json.dumps({ | |
"description": description, | |
"title": pr_title | |
if pr_title: | |
payload = json.dumps({ | |
"description": description, | |
"title": pr_title | |
}) | |
else: | |
logging.error('PR title is empty') | |
return None |
/add_docs |
@@ -246,12 +247,21 @@ def get_commit_messages(self): | |||
return "" # not implemented yet | |||
|
|||
# bitbucket does not support labels | |||
def publish_description(self, pr_title: str, description: str): | |||
def publish_description(self, pr_title: str, pr_body: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Proposed documentation
def publish_description(self, pr_title: str, pr_body: str): | |
""" | |
This method updates the description and title of a pull request in Bitbucket. | |
:param pr_title: The title of the pull request | |
:type pr_title: str | |
:param pr_body: The body of the pull request | |
:type pr_body: str | |
:return: The response from the Bitbucket API | |
:rtype: requests.Response | |
""" | |
def publish_description(self, pr_title: str, pr_body: str): |
PR Analysis
PR Feedback
How to use
|
To resolve this issue, I've implemented a regular expression (regex) to extract the description from the entire body sent by the pr_description. As a result, both the description and title for pull requests are now being updated correctly.
here is the screenshot: