-
Notifications
You must be signed in to change notification settings - Fork 562
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
Changes from all commits
ed1816a
ca8997b
6a72df0
3b9726f
c4432c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||||||||||||||||||||
import json | ||||||||||||||||||||||||
import logging | ||||||||||||||||||||||||
import re | ||||||||||||||||||||||||
from typing import Optional, Tuple | ||||||||||||||||||||||||
from urllib.parse import urlparse | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
@@ -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): | ||||||||||||||||||||||||
pattern = r"## PR Description:\s*(.*?)\n___" | ||||||||||||||||||||||||
match = re.search(pattern, pr_body, re.DOTALL) | ||||||||||||||||||||||||
okotek marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+251
to
+252
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Suggested change
|
||||||||||||||||||||||||
description = "" | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if match: | ||||||||||||||||||||||||
pr_description = match.group(1).strip() | ||||||||||||||||||||||||
if pr_description: | ||||||||||||||||||||||||
description = pr_description | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
payload = json.dumps({ | ||||||||||||||||||||||||
"description": description, | ||||||||||||||||||||||||
"title": pr_title | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Comment on lines
260
to
263
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Suggested change
|
||||||||||||||||||||||||
}) | ||||||||||||||||||||||||
}) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
response = requests.request("PUT", self.bitbucket_pull_request_api_url, headers=self.headers, data=payload) | ||||||||||||||||||||||||
return response | ||||||||||||||||||||||||
Comment on lines
266
to
267
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Suggested change
|
||||||||||||||||||||||||
|
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