Skip to content

Commit

Permalink
use a more modern version
Browse files Browse the repository at this point in the history
  • Loading branch information
mrT23 committed Nov 12, 2024
1 parent 0657770 commit cbd490b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pr_agent/git_providers/bitbucket_server_provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import LooseVersion
from packaging.version import parse as parse_version
from typing import Optional, Tuple
from urllib.parse import quote_plus, urlparse

Expand Down Expand Up @@ -36,7 +36,7 @@ def __init__(
token=get_settings().get("BITBUCKET_SERVER.BEARER_TOKEN",
None))
try:
self.bitbucket_api_version = LooseVersion(self.bitbucket_client.get("rest/api/1.0/application-properties").get('version'))
self.bitbucket_api_version = parse_version(self.bitbucket_client.get("rest/api/1.0/application-properties").get('version'))
except Exception:
self.bitbucket_api_version = None

Expand Down Expand Up @@ -160,7 +160,7 @@ def get_diff_files(self) -> list[FilePatchInfo]:
head_sha = self.pr.fromRef['latestCommit']

# if Bitbucket api version is >= 8.16 then use the merge-base api for 2-way diff calculation
if self.bitbucket_api_version is not None and self.bitbucket_api_version >= LooseVersion("8.16"):
if self.bitbucket_api_version is not None and self.bitbucket_api_version >= parse_version("8.16"):
try:
base_sha = self.bitbucket_client.get(self._get_merge_base())['id']
except Exception as e:
Expand All @@ -175,7 +175,7 @@ def get_diff_files(self) -> list[FilePatchInfo]:
# if Bitbucket api version is None or < 7.0 then do a simple diff with a guaranteed common ancestor
base_sha = source_commits_list[-1]['parents'][0]['id']
# if Bitbucket api version is 7.0-8.15 then use 2-way diff functionality for the base_sha
if self.bitbucket_api_version is not None and self.bitbucket_api_version >= LooseVersion("7.0"):
if self.bitbucket_api_version is not None and self.bitbucket_api_version >= parse_version("7.0"):
try:
destination_commits = list(
self.bitbucket_client.get_commits(self.workspace_slug, self.repo_slug, base_sha,
Expand Down

0 comments on commit cbd490b

Please sign in to comment.