fix improve, update_changelog and review inline comment

This commit is contained in:
sarbjitgrewal
2023-08-24 11:52:20 +05:30
parent b1a2e3e323
commit 67ff50583a
4 changed files with 27 additions and 7 deletions

View File

@ -6,7 +6,7 @@ from urllib.parse import urlparse
import requests
from atlassian.bitbucket import Cloud
from ..algo.pr_processing import clip_tokens
from ..algo.pr_processing import clip_tokens, find_line_number_of_relevant_line_in_file
from ..config_loader import get_settings
from .git_provider import FilePatchInfo
@ -87,7 +87,7 @@ class BitbucketProvider:
return False
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', 'publish_inline_comments', 'get_labels']:
return False
return True
@ -122,7 +122,20 @@ class BitbucketProvider:
except Exception as e:
logging.exception(f"Failed to remove temp comments, error: {e}")
def publish_inline_comment(self, comment: str, from_line: int, to_line: int, file: str):
# funtion to create_inline_comment
def create_inline_comment(self, body: str, relevant_file: str, relevant_line_in_file: str):
position, absolute_position = find_line_number_of_relevant_line_in_file(self.get_diff_files(), relevant_file.strip('`'), relevant_line_in_file)
if position == -1:
if get_settings().config.verbosity_level >= 2:
logging.info(f"Could not find position for {relevant_file} {relevant_line_in_file}")
subject_type = "FILE"
else:
subject_type = "LINE"
path = relevant_file.strip()
return dict(body=body, path=path, position=absolute_position) if subject_type == "LINE" else {}
def publish_inline_comment(self, comment: str, from_line: int, file: str):
payload = json.dumps( {
"content": {
"raw": comment,
@ -144,7 +157,11 @@ class BitbucketProvider:
def publish_inline_comments(self, comments: list[dict]):
for comment in comments:
self.publish_inline_comment(comment['body'], comment['start_line'], comment['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):
return self.pr.title