| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 35c8c82 commit b325bd7
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,6 +95,10 @@ Fork a project:: | |||
| 95 | 95 | # fork to a specific namespace | |
| 96 | 96 | fork = project.forks.create({'namespace': 'myteam'}) | |
| 97 | 97 | ||
| 98 | + Get a list of forks for the project:: | ||
| 99 | + | ||
| 100 | + forks = project.forks.list() | ||
| 101 | + | ||
| 98 | 102 | Create/delete a fork relation between projects (requires admin permissions):: | |
| 99 | 103 | ||
| 100 | 104 | project.create_fork_relation(source_project.id) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1645,7 +1645,7 @@ class ProjectFork(RESTObject): | |||
| 1645 | 1645 | pass | |
| 1646 | 1646 | ||
| 1647 | 1647 | ||
| 1648 | - class ProjectForkManager(CreateMixin, RESTManager): | ||
| 1648 | + class ProjectForkManager(CreateMixin, ListMixin, RESTManager): | ||
| 1649 | 1649 | _path = '/projects/%(project_id)s/fork' | |
| 1650 | 1650 | _obj_cls = ProjectFork | |
| 1651 | 1651 | _from_parent_attrs = {'project_id': 'id'} | |
@@ -1655,6 +1655,28 @@ class ProjectForkManager(CreateMixin, RESTManager): | |||
| 1655 | 1655 | 'with_merge_requests_enabled') | |
| 1656 | 1656 | _create_attrs = (tuple(), ('namespace', )) | |
| 1657 | 1657 | ||
| 1658 | + def list(self, **kwargs): | ||
| 1659 | + """Retrieve a list of objects. | ||
| 1660 | + | ||
| 1661 | + Args: | ||
| 1662 | + all (bool): If True, return all the items, without pagination | ||
| 1663 | + per_page (int): Number of items to retrieve per request | ||
| 1664 | + page (int): ID of the page to return (starts with page 1) | ||
| 1665 | + as_list (bool): If set to False and no pagination option is | ||
| 1666 | + defined, return a generator instead of a list | ||
| 1667 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 1668 | + | ||
| 1669 | + Returns: | ||
| 1670 | + list: The list of objects, or a generator if `as_list` is False | ||
| 1671 | + | ||
| 1672 | + Raises: | ||
| 1673 | + GitlabAuthenticationError: If authentication is not correct | ||
| 1674 | + GitlabListError: If the server cannot perform the request | ||
| 1675 | + """ | ||
| 1676 | + | ||
| 1677 | + path = self._compute_path('/projects/%(project_id)s/forks') | ||
| 1678 | + return ListMixin.list(self, path=path, **kwargs) | ||
| 1679 | + | ||
| 1658 | 1680 | ||
| 1659 | 1681 | class ProjectHook(SaveMixin, ObjectDeleteMixin, RESTObject): | |
| 1660 | 1682 | _short_print_attr = 'url' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -467,6 +467,9 @@ | |||
| 467 | 467 | p = gl.projects.get(fork.id) | |
| 468 | 468 | assert(p.forked_from_project['id'] == admin_project.id) | |
| 469 | 469 | ||
| 470 | + forks = admin_project.forks.list() | ||
| 471 | + assert(fork.id in map(lambda p: p.id, forks)) | ||
| 472 | + | ||
| 470 | 473 | # project hooks | |
| 471 | 474 | hook = admin_project.hooks.create({'url': 'http://hook.url'}) | |
| 472 | 475 | assert(len(admin_project.hooks.list()) == 1) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments