Skip to content

Commit 571a382

Browse files
author
Gauvain Pocentek
committed
MR: add support for closes_issues
1 parent f6a51d6 commit 571a382

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

gitlab/cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
'filepath']},
4343
'builds': {'required': ['id', 'project-id']}},
4444
gitlab.ProjectMergeRequest: {
45+
'closes-issues': {'required': ['id', 'project-id']},
4546
'cancel': {'required': ['id', 'project-id']},
4647
'merge': {'required': ['id', 'project-id'],
4748
'optional': ['merge-commit-message',
@@ -224,6 +225,14 @@ def do_project_build_retry(self, cls, gl, what, args):
224225
except Exception as e:
225226
_die("Impossible to retry project build (%s)" % str(e))
226227

228+
def do_project_merge_request_closesissues(self, cls, gl, what, args):
229+
try:
230+
o = self.do_get(cls, gl, what, args)
231+
return o.closes_issues()
232+
except Exception as e:
233+
_die("Impossible to list issues closed by merge request (%s)" %
234+
str(e))
235+
227236
def do_project_merge_request_cancel(self, cls, gl, what, args):
228237
try:
229238
o = self.do_get(cls, gl, what, args)

gitlab/objects.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,20 @@ def cancel_merge_when_build_succeeds(self, **kwargs):
10971097
raise_error_from_response(r, errors)
10981098
return ProjectMergeRequest(self, r.json())
10991099

1100+
def closes_issues(self, **kwargs):
1101+
"""List issues closed by the MR.
1102+
1103+
Returns:
1104+
list (ProjectIssue): List of closed issues
1105+
1106+
Raises:
1107+
GitlabConnectionError: If the server cannot be reached.
1108+
GitlabGetError: If the server fails to perform the request.
1109+
"""
1110+
url = ('/projects/%s/merge_requests/%s/closes_issues' %
1111+
(self.project_id, self.id))
1112+
return self.gitlab._raw_list(url, ProjectIssue, **kwargs)
1113+
11001114
def merge(self, merge_commit_message=None,
11011115
should_remove_source_branch=False,
11021116
merged_when_build_succeeds=False,

0 commit comments

Comments
 (0)