Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit77d34b3

Browse files
author
Gauvain Pocentek
committed
Merge branch 'add_fork_support' ofhttps://github.com/fgouteroux/python-gitlab into fgouteroux-add_fork_support
2 parents2bf9794 +cedf080 commit77d34b3

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

‎gitlab/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,13 @@ def UserProject(self, id=None, **kwargs):
451451
DeprecationWarning)
452452
returnUserProject._get_list_or_object(self,id,**kwargs)
453453

454+
defProjectFork(self,id=None,**kwargs):
455+
"""Fork a project for a user.
456+
457+
id must be a dict.
458+
"""
459+
returnProjectFork._get_list_or_object(self,id,**kwargs)
460+
454461
def_list_projects(self,url,**kwargs):
455462
r=self._raw_get(url,**kwargs)
456463
raise_error_from_response(r,GitlabListError)

‎gitlab/objects.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,15 @@ class ProjectEventManager(BaseManager):
545545
obj_cls=ProjectEvent
546546

547547

548+
classProjectFork(GitlabObject):
549+
_url='/projects/fork/%(project_id)s'
550+
canUpdate=False
551+
canDelete=False
552+
canList=False
553+
canGet=False
554+
requiredUrlAttrs= ['project_id']
555+
556+
548557
classProjectHook(GitlabObject):
549558
_url='/projects/%(project_id)s/hooks'
550559
requiredUrlAttrs= ['project_id']
@@ -956,6 +965,25 @@ def delete_file(self, path, branch, message, **kwargs):
956965
r=self.gitlab._raw_delete(url,**kwargs)
957966
raise_error_from_response(r,GitlabDeleteError)
958967

968+
defcreate_fork_relation(self,forked_from_id):
969+
"""Create a forked from/to relation between existing projects.
970+
971+
Args:
972+
forked_from_id (int): The ID of the project that was forked from
973+
974+
Raises:
975+
GitlabCreateError: Operation failed
976+
GitlabConnectionError: Connection to GitLab-server failed
977+
"""
978+
url="/projects/%s/fork/%s"% (self.id,forked_from_id)
979+
r=self.gitlab._raw_post(url)
980+
raise_error_from_response(r,GitlabCreateError,201)
981+
982+
defdelete_fork_relation(self):
983+
url="/projects/%s/fork"%self.id
984+
r=self.gitlab._raw_delete(url)
985+
raise_error_from_response(r,GitlabDeleteError)
986+
959987

960988
classTeamMember(GitlabObject):
961989
_url='/user_teams/%(team_id)s/members'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp