Skip to content

Commit 749831e

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master'
2 parents 5df2d32 + 9226daa commit 749831e

File tree

6 files changed

+58
-7
lines changed

6 files changed

+58
-7
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
21+
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.11' ]
2222

2323
steps:
2424
- uses: actions/checkout@v3

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ include atlassian/VERSION
22
include LICENSE
33
include README.rst
44
include tox.ini
5-
include requirements.txt
5+
include requirements.txt
6+
recursive-include tests *

atlassian/bitbucket/__init__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,7 @@ def get_branches(
11541154
limit=None,
11551155
details=True,
11561156
order_by="MODIFICATION",
1157+
boost_matches=False,
11571158
):
11581159
"""
11591160
Retrieve the branches matching the supplied filterText param.
@@ -1167,6 +1168,7 @@ def get_branches(
11671168
fixed system limits. Default by built-in method: None
11681169
:param details: whether to retrieve plugin-provided metadata about each branch
11691170
:param order_by: OPTIONAL: ordering of refs either ALPHABETICAL (by name) or MODIFICATION (last updated)
1171+
:param boost_matches: Controls whether exact and prefix matches will be boosted to the top
11701172
:return:
11711173
"""
11721174
url = self._url_repo_branches(project_key, repository_slug)
@@ -1182,6 +1184,7 @@ def get_branches(
11821184
if order_by:
11831185
params["orderBy"] = order_by
11841186
params["details"] = details
1187+
params["boostMatches"] = boost_matches
11851188
return self._get_paged(url, params=params)
11861189

11871190
def _url_repo_default_branche(self, project_key, repository_slug):
@@ -1588,6 +1591,37 @@ def get_pull_requests(
15881591
params["at"] = at
15891592
return self._get_paged(url, params=params)
15901593

1594+
def get_required_reviewers_for_pull_request(
1595+
self, source_project, source_repo, dest_project, dest_repo, source_branch, dest_branch
1596+
):
1597+
"""
1598+
Get required reviewers for PR creation
1599+
:param source_project: the project that the PR source is from
1600+
:param source_repo: the repository that the PR source is from
1601+
:param source_branch: the branch name of the PR
1602+
:param dest_project: the project that the PR destination is from
1603+
:param dest_repo: the repository that the PR destination is from
1604+
:param dest_branch: where the PR is being merged into
1605+
:return:
1606+
"""
1607+
url = "{}/reviewers".format(
1608+
self._url_repo(
1609+
dest_project,
1610+
dest_repo,
1611+
api_root="rest/default-reviewers",
1612+
api_version="1.0",
1613+
)
1614+
)
1615+
source_repo_id = self.get_repo(source_project, source_repo)["id"]
1616+
dest_repo_id = self.get_repo(dest_project, dest_repo)["id"]
1617+
params = {
1618+
"sourceRepoId": source_repo_id,
1619+
"sourceRefId": source_branch,
1620+
"targetRepoId": dest_repo_id,
1621+
"targetRefId": dest_branch,
1622+
}
1623+
return self.get(url, params=params)
1624+
15911625
def open_pull_request(
15921626
self,
15931627
source_project,
@@ -1599,6 +1633,7 @@ def open_pull_request(
15991633
title,
16001634
description,
16011635
reviewers=None,
1636+
include_required_reviewers=False,
16021637
):
16031638
"""
16041639
Create a new pull request between two branches.
@@ -1614,6 +1649,7 @@ def open_pull_request(
16141649
:param title: the title of the PR
16151650
:param description: the description of what the PR does
16161651
:param reviewers: the list of reviewers or a single reviewer of the PR
1652+
:param include_required_reviewers: OPTIONAL defaults to False, include required reviewers for the PR
16171653
:return:
16181654
"""
16191655
body = {
@@ -1642,6 +1678,13 @@ def add_reviewer(reviewer_name):
16421678
entry = {"user": {"name": reviewer_name}}
16431679
body["reviewers"].append(entry)
16441680

1681+
if not self.cloud and include_required_reviewers:
1682+
required_reviewers = self.get_required_reviewers_for_pull_request(
1683+
source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch
1684+
)
1685+
for required_reviewer in required_reviewers:
1686+
add_reviewer(required_reviewer["name"])
1687+
16451688
if reviewers is not None:
16461689
if isinstance(reviewers, str):
16471690
add_reviewer(reviewers)

docs/bitbucket.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Manage code
184184
bitbucket.create_repo(project_key, repository, forkable=False, is_private=True)
185185
186186
# Get branches from repo
187-
bitbucket.get_branches(project, repository, filter='', limit=99999, details=True)
187+
bitbucket.get_branches(project, repository, filter='', limit=99999, details=True, boost_matches=False)
188188
189189
# Creates a branch using the information provided in the request.
190190
# The authenticated user must have REPO_WRITE permission for the context repository to call this resource.
@@ -211,6 +211,9 @@ Manage code
211211
# Reply to a comment of a pull request
212212
bitbucket.add_pull_request_comment(project, repository, pull_request_id, text, parent_id=None)
213213
214+
# Get required reviewers for PR creation
215+
bitbucket.get_required_reviewers_for_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, dest_branch)
216+
214217
# Create a new pull request between two branches.
215218
bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description)
216219
@@ -220,6 +223,9 @@ Manage code
220223
# Create a new pull request between two branches with multiple reviewers.
221224
bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description, reviewers=['name1', 'name2'])
222225
226+
# Create a new pull request between two branches with required reviewers.
227+
bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description, include_required_reviewers=True)
228+
223229
# Delete a pull request
224230
bitbucket.delete_pull_request(project, repository, pull_request_id, pull_request_version)
225231

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
maintainer_email="gonchik.tsymzhitov@gmail.com",
2222
url="https://github.com/atlassian-api/atlassian-python-api",
2323
keywords="atlassian jira core software confluence bitbucket bamboo crowd portfolio tempo servicedesk assets api",
24-
packages=find_packages(include=["atlassian*", "tests*"]),
25-
package_dir={"atlassian": "atlassian", "tests": "tests"},
24+
packages=find_packages(include=["atlassian*"]),
25+
package_dir={"atlassian": "atlassian"},
2626
include_package_data=True,
2727
zip_safe=False,
2828
install_requires=["deprecated", "requests", "six", "oauthlib", "requests_oauthlib"],

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ commands = black --check --diff {[base]linting_targets} --exclude __pycache__
4444
[testenv:mypy]
4545
basepython = python3
4646
skip_install = true
47-
deps = mypy == 0.812
48-
commands = mypy atlassian/
47+
deps =
48+
mypy>=0.812
49+
commands = mypy --install-types --non-interactive atlassian/
4950

5051
[testenv:bandit]
5152
basepython = python3

0 commit comments

Comments
 (0)