summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitlab/cli.py11
-rw-r--r--gitlab/objects.py15
2 files changed, 25 insertions, 1 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py
index bbd2ac4..bc17915 100644
--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -44,7 +44,9 @@ EXTRA_ACTIONS = {
'filepath']},
'builds': {'required': ['id', 'project-id']}},
gitlab.ProjectIssue: {'subscribe': {'required': ['id', 'project-id']},
- 'unsubscribe': {'required': ['id', 'project-id']}},
+ 'unsubscribe': {'required': ['id', 'project-id']},
+ 'move': {'required': ['id', 'project-id',
+ 'to-project-id']}},
gitlab.ProjectMergeRequest: {
'closes-issues': {'required': ['id', 'project-id']},
'cancel': {'required': ['id', 'project-id']},
@@ -280,6 +282,13 @@ class GitlabCLI(object):
except Exception as e:
_die("Impossible to subscribe to issue (%s)" % str(e))
+ def do_project_issue_move(self, cls, gl, what, args):
+ try:
+ o = self.do_get(cls, gl, what, args)
+ o.move(args['to_project_id'])
+ except Exception as e:
+ _die("Impossible to move issue (%s)" % str(e))
+
def do_project_merge_request_closesissues(self, cls, gl, what, args):
try:
o = self.do_get(cls, gl, what, args)
diff --git a/gitlab/objects.py b/gitlab/objects.py
index bdadd38..8638b13 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -1095,6 +1095,21 @@ class ProjectIssue(GitlabObject):
raise_error_from_response(r, GitlabUnsubscribeError)
self._set_from_dict(r.json())
+ def move(self, to_project_id, **kwargs):
+ """Move the issue to another project.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ """
+ url = ('/projects/%(project_id)s/issues/%(issue_id)s/move' %
+ {'project_id': self.project_id, 'issue_id': self.id})
+
+ data = {'to_project_id': to_project_id}
+ data.update(**kwargs)
+ r = self.gitlab._raw_post(url, data=data)
+ raise_error_from_response(r, GitlabUpdateError, 201)
+ self._set_from_dict(r.json())
+
class ProjectIssueManager(BaseManager):
obj_cls = ProjectIssue