Read about our upcoming Code of Conduct on this issue

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

Project: new api_fork() method

Proper testing of Git operation will need this.
parent 53b9d19169dd
......@@ -527,6 +527,31 @@ class Project(object):
assert split_url[-2] == 'merge_requests'
return int(split_url[-1])
def api_fork(self, user, group=None):
data = dict(id=self.id)
if group is None:
group = UserNameSpace(user_name=user.name, heptapod=self.heptapod)
else:
data['namespace_id'] = group.id
resp = self.api_request('POST', user, subpath='fork', data=data)
assert resp.status_code < 400
fork_info = resp.json()
owner_info = fork_info.get('owner')
if owner_info is not None:
assert owner_info['username'] == user.name
fork = self.__class__(
heptapod=self.heptapod,
group=group, name=fork_info['path'],
id=fork_info['id'],
vcs_type=fork_info.get('vcs_type'),
owner=user.name)
return wait_assert(
lambda: fork,
lambda proj: proj.api_get_field('import_status') == 'finished'
)
def api_create_merge_request(self, source,
target='branch/default',
title='Created through API'):
......
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