Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
a29f0c28
Commit
a29f0c28
authored
Jan 16, 2018
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow pagination for WikiVersions on Gitaly request
parent
bd96f2d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
43 deletions
+19
-43
Gemfile.lock
Gemfile.lock
+2
-2
lib/gitlab/git/wiki.rb
lib/gitlab/git/wiki.rb
+13
-19
lib/gitlab/gitaly_client/wiki_service.rb
lib/gitlab/gitaly_client/wiki_service.rb
+4
-22
No files found.
Gemfile.lock
View file @
a29f0c28
...
...
@@ -285,7 +285,7 @@ GEM
po_to_json (>= 1.0.0)
rails (>= 3.2.0)
gherkin-ruby (0.3.2)
gitaly-proto (0.7
3
.0)
gitaly-proto (0.7
4
.0)
google-protobuf (~> 3.1)
grpc (~> 1.0)
github-linguist (4.7.6)
...
...
@@ -1056,7 +1056,7 @@ DEPENDENCIES
gettext (~> 3.2.2)
gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.2.0)
gitaly-proto (~> 0.7
3
.0)
gitaly-proto (~> 0.7
4
.0)
github-linguist (~> 4.7.0)
gitlab-flowdock-git-hook (~> 1.0.1)
gitlab-markup (~> 1.6.2)
...
...
lib/gitlab/git/wiki.rb
View file @
a29f0c28
...
...
@@ -93,15 +93,15 @@ module Gitlab
# :per_page - The number of items per page.
# :limit - Total number of items to return.
def
page_versions
(
page_path
,
options
=
{})
puts
'-'
*
80
puts
options
puts
'-'
*
80
puts
byebug
@repository
.
gitaly_migrate
(
:wiki_page_versions
)
do
|
is_enabled
|
if
is_enabled
gitaly_wiki_client
.
page_versions
(
page_path
,
pagination_params
(
options
))
versions
=
gitaly_wiki_client
.
page_versions
(
page_path
,
options
)
# Gitaly uses gollum-lib to get the versions. Gollum defaults to 20
# per page, but also fetches 20 if `limit` or `per_page` < 20.
# Slicing returns an array with the expected number of items.
slice_bound
=
options
[
:limit
]
||
options
[
:per_page
]
||
Gollum
::
Page
.
per_page
versions
[
0
..
slice_bound
]
else
current_page
=
gollum_page_by_path
(
page_path
)
...
...
@@ -136,21 +136,15 @@ module Gitlab
# :per_page - The number of items per page.
# :limit - Total number of items to return.
def
commits_from_page
(
gollum_page
,
options
=
{})
pagination_options
=
pagination_params
(
options
)
unless
options
[
:limit
]
options
[
:offset
]
=
([
1
,
options
.
delete
(
:page
).
to_i
].
max
-
1
)
*
Gollum
::
Page
.
per_page
options
[
:limit
]
=
(
options
.
delete
(
:per_page
)
||
Gollum
::
Page
.
per_page
).
to_i
end
@repository
.
log
(
ref:
gollum_page
.
last_version
.
id
,
path:
gollum_page
.
path
,
limit:
pagination_options
[
:limit
],
offset:
pagination_options
[
:offset
])
end
def
pagination_params
(
options
)
return
options
if
options
[
:limit
]
options
=
options
.
dup
options
[
:offset
]
=
([
1
,
options
.
delete
(
:page
).
to_i
].
max
-
1
)
*
Gollum
::
Page
.
per_page
options
[
:limit
]
=
(
options
.
delete
(
:per_page
)
||
Gollum
::
Page
.
per_page
).
to_i
options
limit:
options
[
:limit
],
offset:
options
[
:offset
])
end
def
gollum_wiki
...
...
lib/gitlab/gitaly_client/wiki_service.rb
View file @
a29f0c28
...
...
@@ -108,38 +108,20 @@ module Gitlab
def
page_versions
(
page_path
,
options
)
request
=
Gitaly
::
WikiGetPageVersionsRequest
.
new
(
repository:
@gitaly_repo
,
page_path:
encode_binary
(
page_path
)
page_path:
encode_binary
(
page_path
),
page:
options
[
:page
]
||
1
,
per_page:
options
[
:per_page
]
||
Gollum
::
Page
.
per_page
)
min_index
=
options
[
:offset
].
to_i
max_index
=
min_index
+
options
[
:limit
].
to_i
byebug
stream
=
GitalyClient
.
call
(
@repository
.
storage
,
:wiki_service
,
:wiki_get_page_versions
,
request
)
version_index
=
0
versions
=
[]
# Allow limit and offset to be send to Gitaly: TODO
stream
.
each
do
|
message
|
puts
'§'
*
80
puts
version_index
message
.
versions
.
each
do
|
version
|
case
version_index
when
min_index
...
max_index
versions
<<
new_wiki_page_version
(
version
)
when
max_index
..
Float
::
INFINITY
return
versions
end
version_index
+=
1
puts
version_index
versions
<<
new_wiki_page_version
(
version
)
end
end
# when we're requesting page 99 but the stream doesn't go that far, whatever
# is fetched thus far
versions
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment