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
Jérome Perrin
gitlab-ce
Commits
9c16958c
Commit
9c16958c
authored
Sep 11, 2017
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate Gitlab::Git::Repository#log to Gitaly
parent
4d88f649
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
2 deletions
+44
-2
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+7
-1
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+8
-0
lib/gitlab/gitaly_client/commit_service.rb
lib/gitlab/gitaly_client/commit_service.rb
+20
-0
spec/lib/gitlab/git/commit_spec.rb
spec/lib/gitlab/git/commit_spec.rb
+9
-1
No files found.
lib/gitlab/git/repository.rb
View file @
9c16958c
...
...
@@ -386,7 +386,13 @@ module Gitlab
options
[
:limit
]
||=
0
options
[
:offset
]
||=
0
raw_log
(
options
).
map
{
|
c
|
Commit
.
decorate
(
self
,
c
)
}
gitaly_migrate
(
:find_commits
)
do
|
is_enabled
|
if
is_enabled
gitaly_commit_client
.
find_commits
(
options
)
else
raw_log
(
options
).
map
{
|
c
|
Commit
.
decorate
(
self
,
c
)
}
end
end
end
# Used in gitaly-ruby
...
...
lib/gitlab/gitaly_client.rb
View file @
9c16958c
...
...
@@ -228,10 +228,18 @@ module Gitlab
path
.
read
.
chomp
end
def
self
.
timestamp
(
t
)
Google
::
Protobuf
::
Timestamp
.
new
(
seconds:
t
.
to_i
)
end
def
self
.
encode
(
s
)
s
.
dup
.
force_encoding
(
Encoding
::
ASCII_8BIT
)
end
def
self
.
encode_repeated
(
a
)
Google
::
Protobuf
::
RepeatedField
.
new
(
:bytes
,
a
.
map
{
|
s
|
self
.
encode
(
s
)
}
)
end
# Count a stack. Used for n+1 detection
def
self
.
count_stack
return
unless
RequestStore
.
active?
...
...
lib/gitlab/gitaly_client/commit_service.rb
View file @
9c16958c
...
...
@@ -230,6 +230,26 @@ module Gitlab
GitalyClient
.
call
(
@repository
.
storage
,
:commit_service
,
:commit_stats
,
request
)
end
def
find_commits
(
options
)
request
=
Gitaly
::
FindCommitsRequest
.
new
(
repository:
@gitaly_repo
,
limit:
options
[
:limit
],
offset:
options
[
:offset
],
follow:
options
[
:follow
],
skip_merges:
options
[
:skip_merges
],
disable_walk:
options
[
:disable_walk
]
)
request
.
after
=
GitalyClient
.
timestamp
(
options
[
:after
])
if
options
[
:after
]
request
.
before
=
GitalyClient
.
timestamp
(
options
[
:before
])
if
options
[
:before
]
request
.
revision
=
GitalyClient
.
encode
(
options
[
:ref
])
if
options
[
:ref
]
request
.
paths
=
GitalyClient
.
encode_repeated
(
Array
(
options
[
:path
]))
if
options
[
:path
].
present?
response
=
GitalyClient
.
call
(
@repository
.
storage
,
:commit_service
,
:find_commits
,
request
)
consume_commits_response
(
response
)
end
private
def
call_commit_diff
(
request_params
,
options
=
{})
...
...
spec/lib/gitlab/git/commit_spec.rb
View file @
9c16958c
...
...
@@ -181,7 +181,7 @@ describe Gitlab::Git::Commit, seed_helper: true do
end
end
describe
'.where'
do
shared_examples
'.where'
do
context
'path is empty string'
do
subject
do
commits
=
described_class
.
where
(
...
...
@@ -279,6 +279,14 @@ describe Gitlab::Git::Commit, seed_helper: true do
end
end
describe
'.where with gitaly'
do
it_should_behave_like
'.where'
end
describe
'.where without gitaly'
,
skip_gitaly_mock:
true
do
it_should_behave_like
'.where'
end
describe
'.between'
do
subject
do
commits
=
described_class
.
between
(
repository
,
SeedRepo
::
Commit
::
PARENT_ID
,
SeedRepo
::
Commit
::
ID
)
...
...
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