|
@@ -1,12 +1,11 @@
|
|
|
import datetime
|
|
|
from urllib.parse import urlparse
|
|
|
|
|
|
-from unidiff import PatchSet
|
|
|
-
|
|
|
from sentry.integrations.client import ApiClient
|
|
|
from sentry.integrations.utils import get_query_hash
|
|
|
from sentry.utils import jwt
|
|
|
from sentry.utils.http import absolute_uri
|
|
|
+from sentry.utils.patch_set import patch_to_file_changes
|
|
|
|
|
|
BITBUCKET_KEY = f"{urlparse(absolute_uri()).hostname}.bitbucket"
|
|
|
|
|
@@ -103,26 +102,11 @@ class BitbucketApiClient(ApiClient):
|
|
|
def delete_hook(self, repo, hook_id):
|
|
|
return self.delete(path=BitbucketAPIPath.repository_hook.format(repo=repo, uid=hook_id))
|
|
|
|
|
|
- def transform_patchset(self, patch_set):
|
|
|
- file_changes = []
|
|
|
- for patched_file in patch_set.added_files:
|
|
|
- file_changes.append({"path": patched_file.path, "type": "A"})
|
|
|
-
|
|
|
- for patched_file in patch_set.removed_files:
|
|
|
- file_changes.append({"path": patched_file.path, "type": "D"})
|
|
|
-
|
|
|
- for patched_file in patch_set.modified_files:
|
|
|
- file_changes.append({"path": patched_file.path, "type": "M"})
|
|
|
-
|
|
|
- return file_changes
|
|
|
-
|
|
|
def get_commit_filechanges(self, repo, sha):
|
|
|
resp = self.get(
|
|
|
BitbucketAPIPath.repository_diff.format(repo=repo, spec=sha), allow_text=True
|
|
|
)
|
|
|
- diff_file = resp.text
|
|
|
- ps = PatchSet.from_string(diff_file)
|
|
|
- return self.transform_patchset(ps)
|
|
|
+ return patch_to_file_changes(resp.text)
|
|
|
|
|
|
def zip_commit_data(self, repo, commit_list):
|
|
|
for commit in commit_list:
|