summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2019-06-20 08:50:09 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2019-06-20 08:50:09 +0200
commit90a363154067bcf763043124d172eaf705c8fe90 (patch)
treee5434c9cd7bdf4d1e9492dd95990f17087b55014
parent51751c5f78ec14e416e595fd42f97d55197df347 (diff)
downloadgitlab-feat/related_mr.tar.gz
feat: add support for issue.related_merge_requestsfeat/related_mr
Closes #794
-rw-r--r--docs/gl_objects/issues.rst4
-rw-r--r--gitlab/v4/objects.py18
-rw-r--r--tools/python_test_v4.py2
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 d15bc5d..7ea89ea 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"})