Class: Gitlab::Git::Wiki
Defined Under Namespace
Classes: CommitDetails, GollumSlug
Constant Summary
collapse
- DuplicatePageError =
Class.new(StandardError)
Kaminari.config.default_per_page
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#count_page_versions(page_path) ⇒ Object
-
#delete_page(page_path, commit_details) ⇒ Object
-
#file(name, version) ⇒ Object
-
#initialize(repository) ⇒ Wiki
constructor
Initialize with a Gitlab::Git::Repository instance.
-
#list_pages(limit: 0, sort: nil, direction_desc: false, load_content: false) ⇒ Object
-
#page(title:, version: nil, dir: nil) ⇒ Object
-
#page_versions(page_path, options = {}) ⇒ Object
options: :page - The Integer page number.
-
#preview_slug(title, format) ⇒ Object
-
#repository_exists? ⇒ Boolean
-
#update_page(page_path, title, format, content, commit_details) ⇒ Object
-
#write_page(name, format, content, commit_details) ⇒ Object
#wrapped_gitaly_errors
Constructor Details
#initialize(repository) ⇒ Wiki
Initialize with a Gitlab::Git::Repository instance
62
63
64
|
# File 'lib/gitlab/git/wiki.rb', line 62
def initialize(repository)
@repository = repository
end
|
Instance Attribute Details
#repository ⇒ Object
Returns the value of attribute repository
55
56
57
|
# File 'lib/gitlab/git/wiki.rb', line 55
def repository
@repository
end
|
Class Method Details
.default_ref ⇒ Object
57
58
59
|
# File 'lib/gitlab/git/wiki.rb', line 57
def self.default_ref
'master'
end
|
Instance Method Details
#count_page_versions(page_path) ⇒ Object
131
132
133
|
# File 'lib/gitlab/git/wiki.rb', line 131
def count_page_versions(page_path)
@repository.count_commits(ref: 'HEAD', path: page_path)
end
|
#delete_page(page_path, commit_details) ⇒ Object
76
77
78
79
80
|
# File 'lib/gitlab/git/wiki.rb', line 76
def delete_page(page_path, commit_details)
wrapped_gitaly_errors do
gitaly_delete_page(page_path, commit_details)
end
end
|
#file(name, version) ⇒ Object
109
110
111
112
113
|
# File 'lib/gitlab/git/wiki.rb', line 109
def file(name, version)
wrapped_gitaly_errors do
gitaly_find_file(name, version)
end
end
|
#list_pages(limit: 0, sort: nil, direction_desc: false, load_content: false) ⇒ Object
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/gitlab/git/wiki.rb', line 88
def list_pages(limit: 0, sort: nil, direction_desc: false, load_content: false)
wrapped_gitaly_errors do
gitaly_list_pages(
limit: limit,
sort: sort,
direction_desc: direction_desc,
load_content: load_content
)
end
end
|
#page(title:, version: nil, dir: nil) ⇒ Object
99
100
101
102
103
104
105
106
107
|
# File 'lib/gitlab/git/wiki.rb', line 99
def page(title:, version: nil, dir: nil)
wrapped_gitaly_errors do
gitaly_find_page(title: title, version: version, dir: dir)
end
rescue Gitlab::Git::CommandError
nil
end
|
#page_versions(page_path, options = {}) ⇒ Object
options:
:page - The Integer page number.
:per_page - The number of items per page.
:limit - Total number of items to return.
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/gitlab/git/wiki.rb', line 119
def page_versions(page_path, options = {})
versions = wrapped_gitaly_errors do
gitaly_wiki_client.page_versions(page_path, options)
end
slice_bound = options[:limit] || options[:per_page] || DEFAULT_PAGINATION
versions[0..slice_bound]
end
|
#preview_slug(title, format) ⇒ Object
135
136
137
|
# File 'lib/gitlab/git/wiki.rb', line 135
def preview_slug(title, format)
GollumSlug.generate(title, format)
end
|
#repository_exists? ⇒ Boolean
66
67
68
|
# File 'lib/gitlab/git/wiki.rb', line 66
def repository_exists?
@repository.exists?
end
|
#update_page(page_path, title, format, content, commit_details) ⇒ Object
82
83
84
85
86
|
# File 'lib/gitlab/git/wiki.rb', line 82
def update_page(page_path, title, format, content, commit_details)
wrapped_gitaly_errors do
gitaly_update_page(page_path, title, format, content, commit_details)
end
end
|
#write_page(name, format, content, commit_details) ⇒ Object
70
71
72
73
74
|
# File 'lib/gitlab/git/wiki.rb', line 70
def write_page(name, format, content, commit_details)
wrapped_gitaly_errors do
gitaly_write_page(name, format, content, commit_details)
end
end
|