|
3 | 3 | from ..base import BitbucketCloudBase
|
4 | 4 | from ..common.builds import Build
|
5 | 5 | from ..common.comments import Comment
|
6 |
| -from ..common.users import User, Participant |
| 6 | +from ..common.users import Participant, User |
7 | 7 |
|
8 | 8 |
|
9 | 9 | class Commits(BitbucketCloudBase):
|
@@ -186,3 +186,29 @@ def unapprove(self):
|
186 | 186 | API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-approve-delete
|
187 | 187 | """
|
188 | 188 | return super(BitbucketCloudBase, self).delete("approve")
|
| 189 | + |
| 190 | + def get_pull_requests(self, start=0, pagelen=0): |
| 191 | + """ |
| 192 | + Retrieves pull requests associated with the current commit. |
| 193 | +
|
| 194 | + Pull Request Commit Links app must be installed first before using this API; |
| 195 | + installation automatically occurs when 'Go to pull request' is clicked |
| 196 | + from the web interface for a commit's details. |
| 197 | +
|
| 198 | + API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get |
| 199 | +
|
| 200 | + :param start: int, OPTIONAL: The starting page of pull requests to retrieve. Defaults to 0. |
| 201 | + :param pagelen: int, OPTIONAL: The number of pull requests to retrieve per page. Defaults to 0. |
| 202 | + :return: Generator[PullRequest]: A generator that yields `PullRequest` objects. |
| 203 | + """ |
| 204 | + # NOTE: Import moved inside the method to avoid circular import issues |
| 205 | + from ...cloud.repositories.pullRequests import PullRequest |
| 206 | + |
| 207 | + params = {} |
| 208 | + if start: |
| 209 | + params["page"] = start |
| 210 | + if pagelen: |
| 211 | + params["pagelen"] = pagelen |
| 212 | + |
| 213 | + for pull_request in self._get_paged(url="pullrequests", params=params): |
| 214 | + yield PullRequest(pull_request, **self._new_session_args) |
0 commit comments