mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 21:00:40 +08:00
Fix missing self.bearer_token for bitbucket related providers
This commit is contained in:
@ -30,12 +30,15 @@ class BitbucketProvider(GitProvider):
|
|||||||
):
|
):
|
||||||
s = requests.Session()
|
s = requests.Session()
|
||||||
try:
|
try:
|
||||||
bearer = context.get("bitbucket_bearer_token", None)
|
self.bearer_token = bearer = context.get("bitbucket_bearer_token", None)
|
||||||
|
if not bearer and get_settings().get("BITBUCKET.BEARER_TOKEN", None):
|
||||||
|
self.bearer_token = bearer = get_settings().get("BITBUCKET.BEARER_TOKEN", None)
|
||||||
s.headers["Authorization"] = f"Bearer {bearer}"
|
s.headers["Authorization"] = f"Bearer {bearer}"
|
||||||
except Exception:
|
except Exception:
|
||||||
|
self.bearer_token = get_settings().get("BITBUCKET.BEARER_TOKEN", None)
|
||||||
s.headers[
|
s.headers[
|
||||||
"Authorization"
|
"Authorization"
|
||||||
] = f'Bearer {get_settings().get("BITBUCKET.BEARER_TOKEN", None)}'
|
] = f'Bearer {self.bearer_token}'
|
||||||
s.headers["Content-Type"] = "application/json"
|
s.headers["Content-Type"] = "application/json"
|
||||||
self.headers = s.headers
|
self.headers = s.headers
|
||||||
self.bitbucket_client = Cloud(session=s)
|
self.bitbucket_client = Cloud(session=s)
|
||||||
@ -488,7 +491,7 @@ class BitbucketProvider(GitProvider):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_pr_url(pr_url: str) -> Tuple[str, int]:
|
def _parse_pr_url(pr_url: str) -> Tuple[str, int, int]:
|
||||||
parsed_url = urlparse(pr_url)
|
parsed_url = urlparse(pr_url)
|
||||||
|
|
||||||
if "bitbucket.org" not in parsed_url.netloc:
|
if "bitbucket.org" not in parsed_url.netloc:
|
||||||
|
@ -36,7 +36,7 @@ class BitbucketServerProvider(GitProvider):
|
|||||||
self.incremental = incremental
|
self.incremental = incremental
|
||||||
self.diff_files = None
|
self.diff_files = None
|
||||||
self.bitbucket_pull_request_api_url = pr_url
|
self.bitbucket_pull_request_api_url = pr_url
|
||||||
|
self.bearer_token = get_settings().get("BITBUCKET_SERVER.BEARER_TOKEN", None)
|
||||||
self.bitbucket_server_url = self._parse_bitbucket_server(url=pr_url)
|
self.bitbucket_server_url = self._parse_bitbucket_server(url=pr_url)
|
||||||
self.bitbucket_client = bitbucket_client or Bitbucket(url=self.bitbucket_server_url,
|
self.bitbucket_client = bitbucket_client or Bitbucket(url=self.bitbucket_server_url,
|
||||||
token=get_settings().get("BITBUCKET_SERVER.BEARER_TOKEN",
|
token=get_settings().get("BITBUCKET_SERVER.BEARER_TOKEN",
|
||||||
@ -67,7 +67,7 @@ class BitbucketServerProvider(GitProvider):
|
|||||||
desired_branch = self.get_pr_branch()
|
desired_branch = self.get_pr_branch()
|
||||||
workspace_name = self.workspace_slug
|
workspace_name = self.workspace_slug
|
||||||
project_name = self.repo_slug
|
project_name = self.repo_slug
|
||||||
else:
|
elif '.git' in repo_git_url and 'scm/' in repo_git_url:
|
||||||
repo_path = repo_git_url.split('.git')[0].split('scm/')[-1]
|
repo_path = repo_git_url.split('.git')[0].split('scm/')[-1]
|
||||||
if repo_path.count('/') == 1: # Has to have the form <workspace>/<repo>
|
if repo_path.count('/') == 1: # Has to have the form <workspace>/<repo>
|
||||||
workspace_name, project_name = repo_path.split('/')
|
workspace_name, project_name = repo_path.split('/')
|
||||||
|
Reference in New Issue
Block a user