diff options
author | Max Wittig <max.wittig95@gmail.com> | 2019-07-01 18:41:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-01 18:41:58 +0200 |
commit | ad1c0dda37f573673beaf9f25187f51751a5a484 (patch) | |
tree | 95a823cfc4e31eb99ec5a6449da9878284343f75 | |
parent | f539c36dddf8e0eb3b2156a3ed4e2ff2fa667cf1 (diff) | |
parent | 90a363154067bcf763043124d172eaf705c8fe90 (diff) | |
download | gitlab-ad1c0dda37f573673beaf9f25187f51751a5a484.tar.gz |
Merge pull request #803 from python-gitlab/feat/related_mr
feat: add support for issue.related_merge_requests
-rw-r--r-- | docs/gl_objects/issues.rst | 4 | ||||
-rw-r--r-- | gitlab/v4/objects.py | 18 | ||||
-rw-r--r-- | tools/python_test_v4.py | 2 |
3 files changed, 24 insertions, 0 deletions
diff --git a/docs/gl_objects/issues.rst b/docs/gl_objects/issues.rst index 12df90b..6823da0 100644 --- a/docs/gl_objects/issues.rst +++ b/docs/gl_objects/issues.rst @@ -180,6 +180,10 @@ Get the list of merge requests that will close an issue when merged:: mrs = issue.closed_by() +Get the merge requests related to an issue:: + + mrs = issue.related_merge_requests() + Get the list of participants:: users = issue.participants() diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 9a76d8d..f452aa7 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -2188,6 +2188,24 @@ class ProjectIssue( @cli.register_custom_action("ProjectIssue") @exc.on_http_error(exc.GitlabGetError) + def related_merge_requests(self, **kwargs): + """List merge requests related to the issue. + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabGetErrot: If the merge requests could not be retrieved + + Returns: + list: The list of merge requests. + """ + path = "%s/%s/related_merge_requests" % (self.manager.path, self.get_id()) + return self.manager.gitlab.http_get(path, **kwargs) + + @cli.register_custom_action("ProjectIssue") + @exc.on_http_error(exc.GitlabGetError) def closed_by(self, **kwargs): """List merge requests that will close the issue when merged. diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py index 07f3589..358f2e4 100644 --- a/tools/python_test_v4.py +++ b/tools/python_test_v4.py @@ -566,6 +566,8 @@ assert isinstance(issue1.user_agent_detail(), dict) assert issue1.user_agent_detail()["user_agent"] assert issue1.participants() +assert type(issue1.closed_by()) == list +assert type(issue1.related_merge_requests()) == list # issues labels and events label2 = admin_project.labels.create({"name": "label2", "color": "#aabbcc"}) |