Commit bc0b8fb2 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Project: target_project parameter for MR creation from fork.

We chose to pass a whole Project instance, because it's seem
very unlikely we'd have a use case for passing an id (caller
would have created the target Project or would use a fixture),
and therefore it makes things simpler on the average for the caller.
parent cc370c57bf00
......@@ -554,6 +554,7 @@ class Project(object):
def api_create_merge_request(self, source,
target='branch/default',
target_project=None,
title='Created through API'):
"""As the project owner, create a merge request through API.
......@@ -561,14 +562,18 @@ class Project(object):
:param source: name of the source branch for GitLab, e.g.,
'topic/default/foo'
:param target: name of the target branch for GitLab
:param target_project: target :class:`Project` instance, defaults to
``self``, which is already the source project.
:returns: numeric iid of the newly created MR
"""
resp = self.owner_api_post(subpath='merge_requests',
data=dict(id=self.id,
data = dict(id=self.id,
source_branch=source,
target_branch=target,
title=title,
))
title=title)
if target_project is not None:
data['target_project_id'] = target_project.id
resp = self.owner_api_post(subpath='merge_requests', data=data)
assert resp.status_code in (200, 201)
return resp.json()['iid']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment