From 0981fe3c9facf681f51aede8c8ff29264469b712 Mon Sep 17 00:00:00 2001 From: nborisenko Date: Tue, 13 Jul 2021 16:54:58 +0300 Subject: [PATCH 1/3] Update __init__.py --- atlassian/bitbucket/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/atlassian/bitbucket/__init__.py b/atlassian/bitbucket/__init__.py index f9c73d06f..a3eba3ebb 100644 --- a/atlassian/bitbucket/__init__.py +++ b/atlassian/bitbucket/__init__.py @@ -1236,8 +1236,11 @@ def set_tag(self, project_key, repository_slug, tag_name, commit_revision, descr if tag_name is not None: body["name"] = tag_name if tag_name is not None: - body["startPoint"] = commit_revision - if tag_name is not None: + if self.cloud: + body["target"] = {"hash": commit_revision} + else: + body["startPoint"] = commit_revision + if tag_name is not None and not self.cloud: body["message"] = description return self.post(url, data=body) @@ -1971,6 +1974,7 @@ def get_commits( avatar_size=None, avatar_scheme=None, limit=None, + branch="" ): """ Get commit list from repo @@ -1989,6 +1993,8 @@ def get_commits( :return: """ url = self._url_commits(project_key, repository_slug) + if branch: + url = "{}/{}".format(url, branch) params = {"merges": merges} if hash_oldest: params["since"] = hash_oldest From ef57caa37270fda1734106fdcc90d387d49e83eb Mon Sep 17 00:00:00 2001 From: Dmitriy Miroshnik Date: Tue, 28 Sep 2021 14:18:11 +0300 Subject: [PATCH 2/3] add get_commits pagination --- atlassian/bitbucket/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/atlassian/bitbucket/__init__.py b/atlassian/bitbucket/__init__.py index a3eba3ebb..cc9685bc3 100644 --- a/atlassian/bitbucket/__init__.py +++ b/atlassian/bitbucket/__init__.py @@ -2012,7 +2012,15 @@ def get_commits( params["avatarScheme"] = avatar_scheme if limit: params["limit"] = limit - return (self.get(url, params=params) or {}).get("values") + commits = [] + response = (self.get(url, params=params) or {}) + if response is {}: + return [] + commits += response.get('values') + while len(commits) < limit and 'next' in response.keys(): + response = self.get(response['next'], params=params, absolute=True) + commits += response.get('values') + return commits[:limit] if len(commits) > limit else commits def _url_commit(self, project_key, repository_slug, commit_id, api_root=None, api_version=None): return "{}/{}".format( From 00a5948c4737ab698d2e52f874a7dd1bd177e254 Mon Sep 17 00:00:00 2001 From: nborisenko Date: Wed, 27 Mar 2024 17:49:28 +0200 Subject: [PATCH 3/3] Update commit pagination --- atlassian/bitbucket/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atlassian/bitbucket/__init__.py b/atlassian/bitbucket/__init__.py index cc9685bc3..143dbb9ad 100644 --- a/atlassian/bitbucket/__init__.py +++ b/atlassian/bitbucket/__init__.py @@ -2018,7 +2018,7 @@ def get_commits( return [] commits += response.get('values') while len(commits) < limit and 'next' in response.keys(): - response = self.get(response['next'], params=params, absolute=True) + response = self.get(response['next'], absolute=True) commits += response.get('values') return commits[:limit] if len(commits) > limit else commits