Skip to content

Commit 73627a2

Browse files
author
Gauvain Pocentek
committed
Add support for project-issue move
1 parent ca68f6d commit 73627a2

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

gitlab/cli.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
'filepath']},
4545
'builds': {'required': ['id', 'project-id']}},
4646
gitlab.ProjectIssue: {'subscribe': {'required': ['id', 'project-id']},
47-
'unsubscribe': {'required': ['id', 'project-id']}},
47+
'unsubscribe': {'required': ['id', 'project-id']},
48+
'move': {'required': ['id', 'project-id',
49+
'to-project-id']}},
4850
gitlab.ProjectMergeRequest: {
4951
'closes-issues': {'required': ['id', 'project-id']},
5052
'cancel': {'required': ['id', 'project-id']},
@@ -280,6 +282,13 @@ def do_project_issue_unsubscribe(self, cls, gl, what, args):
280282
except Exception as e:
281283
_die("Impossible to subscribe to issue (%s)" % str(e))
282284

285+
def do_project_issue_move(self, cls, gl, what, args):
286+
try:
287+
o = self.do_get(cls, gl, what, args)
288+
o.move(args['to_project_id'])
289+
except Exception as e:
290+
_die("Impossible to move issue (%s)" % str(e))
291+
283292
def do_project_merge_request_closesissues(self, cls, gl, what, args):
284293
try:
285294
o = self.do_get(cls, gl, what, args)

gitlab/objects.py

+15
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,21 @@ def unsubscribe(self, **kwargs):
10951095
raise_error_from_response(r, GitlabUnsubscribeError)
10961096
self._set_from_dict(r.json())
10971097

1098+
def move(self, to_project_id, **kwargs):
1099+
"""Move the issue to another project.
1100+
1101+
Raises:
1102+
GitlabConnectionError: If the server cannot be reached.
1103+
"""
1104+
url = ('/projects/%(project_id)s/issues/%(issue_id)s/move' %
1105+
{'project_id': self.project_id, 'issue_id': self.id})
1106+
1107+
data = {'to_project_id': to_project_id}
1108+
data.update(**kwargs)
1109+
r = self.gitlab._raw_post(url, data=data)
1110+
raise_error_from_response(r, GitlabUpdateError, 201)
1111+
self._set_from_dict(r.json())
1112+
10981113

10991114
class ProjectIssueManager(BaseManager):
11001115
obj_cls = ProjectIssue

0 commit comments

Comments
 (0)