From e8631c1d505690a04704a9c19ba4a2d8564c6ef4 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Fri, 8 Jan 2016 22:05:37 +0100 Subject: [PATCH] Create a manager for ProjectFork objects --- gitlab/__init__.py | 8 +------- gitlab/objects.py | 5 +++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 4de778a02..02fb1754f 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -88,6 +88,7 @@ def __init__(self, url, private_token=None, self.project_commits = ProjectCommitManager(self) self.project_keys = ProjectKeyManager(self) self.project_events = ProjectEventManager(self) + self.project_forks = ProjectForkManager(self) self.project_hooks = ProjectHookManager(self) self.project_issue_notes = ProjectIssueNoteManager(self) self.project_issues = ProjectIssueManager(self) @@ -451,13 +452,6 @@ def UserProject(self, id=None, **kwargs): DeprecationWarning) return UserProject._get_list_or_object(self, id, **kwargs) - def ProjectFork(self, id=None, **kwargs): - """Fork a project for a user. - - id must be a dict. - """ - return ProjectFork._get_list_or_object(self, id, **kwargs) - def _list_projects(self, url, **kwargs): r = self._raw_get(url, **kwargs) raise_error_from_response(r, GitlabListError) diff --git a/gitlab/objects.py b/gitlab/objects.py index db21eafc4..3637fe8d7 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -554,6 +554,10 @@ class ProjectFork(GitlabObject): requiredUrlAttrs = ['project_id'] +class ProjectForkManager(BaseManager): + obj_cls = ProjectFork + + class ProjectHook(GitlabObject): _url = '/projects/%(project_id)s/hooks' requiredUrlAttrs = ['project_id'] @@ -798,6 +802,7 @@ class Project(GitlabObject): ('commits', ProjectCommitManager, [('project_id', 'id')]), ('events', ProjectEventManager, [('project_id', 'id')]), ('files', ProjectFileManager, [('project_id', 'id')]), + ('forks', ProjectForkManager, [('project_id', 'id')]), ('hooks', ProjectHookManager, [('project_id', 'id')]), ('keys', ProjectKeyManager, [('project_id', 'id')]), ('issues', ProjectIssueManager, [('project_id', 'id')]),