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

Commit74f5e62

Browse files
authored
feat(objects): add support for Group wikis (#1484)
feat(objects): add support for Group wikis
1 parent85bbd1a commit74f5e62

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed

‎docs/gl_objects/wikis.rst

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,37 @@ References
1111
+:class:`gitlab.v4.objects.ProjectWiki`
1212
+:class:`gitlab.v4.objects.ProjectWikiManager`
1313
+:attr:`gitlab.v4.objects.Project.wikis`
14+
+:class:`gitlab.v4.objects.GroupWiki`
15+
+:class:`gitlab.v4.objects.GroupWikiManager`
16+
+:attr:`gitlab.v4.objects.Group.wikis`
1417

15-
* GitLab API: https://docs.gitlab.com/ce/api/wikis.html
18+
* GitLab API for Projects: https://docs.gitlab.com/ce/api/wikis.html
19+
* GitLab API for Groups: https://docs.gitlab.com/ee/api/group_wikis.html
1620

1721
Examples
1822
--------
1923

20-
Get the list of wiki pages for a project::
24+
Get the list of wiki pages for a project. These do not contain the contents of the wiki page. You will need to call get(slug) to retrieve the content by accessing the content attribute::
2125

2226
pages = project.wikis.list()
2327

24-
Get a single wiki page::
28+
Get the list of wiki pages for a group. These do not contain the contents of the wiki page. You will need to call get(slug) to retrieve the content by accessing the content attribute::
29+
30+
pages = group.wikis.list()
31+
32+
Get a single wiki page for a project::
2533

2634
page = project.wikis.get(page_slug)
2735

28-
Create a wiki page::
36+
Get a single wiki page for a group::
37+
38+
page = group.wikis.get(page_slug)
39+
40+
Get the contents of a wiki page::
41+
42+
print(page.content)
43+
44+
Create a wiki page on a project level::
2945

3046
page = project.wikis.create({'title': 'Wiki Page 1',
3147
'content': open(a_file).read()})

‎gitlab/v4/objects/groups.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from .runnersimportGroupRunnerManager# noqa: F401
2929
from .statisticsimportGroupIssuesStatisticsManager# noqa: F401
3030
from .variablesimportGroupVariableManager# noqa: F401
31+
from .wikisimportGroupWikiManager# noqa: F401
3132

3233
__all__= [
3334
"Group",
@@ -67,6 +68,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
6768
("variables","GroupVariableManager"),
6869
("clusters","GroupClusterManager"),
6970
("deploytokens","GroupDeployTokenManager"),
71+
("wikis","GroupWikiManager"),
7072
)
7173

7274
@cli.register_custom_action("Group", ("to_project_id",))

‎gitlab/v4/objects/wikis.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
__all__= [
55
"ProjectWiki",
66
"ProjectWikiManager",
7+
"GroupWiki",
8+
"GroupWikiManager",
79
]
810

911

@@ -21,3 +23,19 @@ class ProjectWikiManager(CRUDMixin, RESTManager):
2123
)
2224
_update_attrs=RequiredOptional(optional=("title","content","format"))
2325
_list_filters= ("with_content",)
26+
27+
28+
classGroupWiki(SaveMixin,ObjectDeleteMixin,RESTObject):
29+
_id_attr="slug"
30+
_short_print_attr="slug"
31+
32+
33+
classGroupWikiManager(CRUDMixin,RESTManager):
34+
_path="/groups/%(group_id)s/wikis"
35+
_obj_cls=GroupWiki
36+
_from_parent_attrs= {"group_id":"id"}
37+
_create_attrs=RequiredOptional(
38+
required=("title","content"),optional=("format",)
39+
)
40+
_update_attrs=RequiredOptional(optional=("title","content","format"))
41+
_list_filters= ("with_content",)

‎tests/functional/api/test_groups.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,18 @@ def test_group_subgroups_projects(gl, user):
194194
assertgroup4.parent_id==group2.id
195195
assertgr1_project.namespace["id"]==group1.id
196196
assertgr2_project.namespace["parent_id"]==group1.id
197+
198+
199+
@pytest.mark.skip
200+
deftest_group_wiki(group):
201+
content="Group Wiki page content"
202+
wiki=group.wikis.create({"title":"groupwikipage","content":content})
203+
assertlen(group.wikis.list())==1
204+
205+
wiki=group.wikis.get(wiki.slug)
206+
assertwiki.content==content
207+
208+
wiki.content="new content"
209+
wiki.save()
210+
wiki.delete()
211+
assertlen(group.wikis.list())==0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp