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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
64cda774
Commit
64cda774
authored
Jun 19, 2018
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LFS changes are detected by Gitaly
Closes
https://gitlab.com/gitlab-org/gitaly/issues/935
parent
b0fadeee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
94 deletions
+7
-94
lib/gitlab/git/lfs_changes.rb
lib/gitlab/git/lfs_changes.rb
+2
-58
spec/lib/gitlab/git/lfs_changes_spec.rb
spec/lib/gitlab/git/lfs_changes_spec.rb
+5
-36
No files found.
lib/gitlab/git/lfs_changes.rb
View file @
64cda774
...
...
@@ -7,67 +7,11 @@ module Gitlab
end
def
new_pointers
(
object_limit:
nil
,
not_in:
nil
)
@repository
.
gitaly_migrate
(
:blob_get_new_lfs_pointers
)
do
|
is_enabled
|
if
is_enabled
@repository
.
gitaly_blob_client
.
get_new_lfs_pointers
(
@newrev
,
object_limit
,
not_in
)
else
git_new_pointers
(
object_limit
,
not_in
)
end
end
@repository
.
gitaly_blob_client
.
get_new_lfs_pointers
(
@newrev
,
object_limit
,
not_in
)
end
def
all_pointers
@repository
.
gitaly_migrate
(
:blob_get_all_lfs_pointers
)
do
|
is_enabled
|
if
is_enabled
@repository
.
gitaly_blob_client
.
get_all_lfs_pointers
(
@newrev
)
else
git_all_pointers
end
end
end
private
def
git_new_pointers
(
object_limit
,
not_in
)
@new_pointers
||=
begin
rev_list
.
new_objects
(
rev_list_params
(
not_in:
not_in
))
do
|
object_ids
|
object_ids
=
object_ids
.
take
(
object_limit
)
if
object_limit
Gitlab
::
Git
::
Blob
.
batch_lfs_pointers
(
@repository
,
object_ids
)
end
end
end
def
git_all_pointers
params
=
{}
if
rev_list_supports_new_options?
params
[
:options
]
=
[
"--filter=blob:limit=
#{
Gitlab
::
Git
::
Blob
::
LFS_POINTER_MAX_SIZE
}
"
]
end
rev_list
.
all_objects
(
rev_list_params
(
params
))
do
|
object_ids
|
Gitlab
::
Git
::
Blob
.
batch_lfs_pointers
(
@repository
,
object_ids
)
end
end
def
rev_list
Gitlab
::
Git
::
RevList
.
new
(
@repository
,
newrev:
@newrev
)
end
# We're passing the `--in-commit-order` arg to ensure we don't wait
# for git to traverse all commits before returning pointers.
# This is required in order to improve the performance of LFS integrity check
def
rev_list_params
(
params
=
{})
params
[
:options
]
||=
[]
params
[
:options
]
<<
"--in-commit-order"
if
rev_list_supports_new_options?
params
[
:require_path
]
=
true
params
end
def
rev_list_supports_new_options?
return
@option_supported
if
defined?
(
@option_supported
)
@option_supported
=
Gitlab
::
Git
.
version
>=
Gitlab
::
VersionInfo
.
parse
(
'2.16.0'
)
@repository
.
gitaly_blob_client
.
get_all_lfs_pointers
(
@newrev
)
end
end
end
...
...
spec/lib/gitlab/git/lfs_changes_spec.rb
View file @
64cda774
require
'spec_helper'
describe
Gitlab
::
Git
::
LfsChanges
do
l
et
(
:project
)
{
create
(
:project
,
:repository
)
}
s
et
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:newrev
)
{
'54fcc214b94e78d7a41a9a8fe6d87a5e59500e51'
}
let
(
:blob_object_id
)
{
'0c304a93cb8430108629bbbcaa27db3343299bc0'
}
subject
{
described_class
.
new
(
project
.
repository
,
newrev
)
}
describe
'#new_pointers'
do
shared_examples
'new pointers'
do
it
'filters new objects to find lfs pointers'
do
expect
(
subject
.
new_pointers
(
not_in:
[]).
first
.
id
).
to
eq
(
blob_object_id
)
end
it
'limits new_objects using object_limit'
do
expect
(
subject
.
new_pointers
(
object_limit:
1
)).
to
eq
([])
end
end
context
'with gitaly enabled'
do
it_behaves_like
'new pointers'
it
'filters new objects to find lfs pointers'
do
expect
(
subject
.
new_pointers
(
not_in:
[]).
first
.
id
).
to
eq
(
blob_object_id
)
end
context
'with gitaly disabled'
,
:skip_gitaly_mock
do
it_behaves_like
'new pointers'
it
'uses rev-list to find new objects'
do
rev_list
=
double
allow
(
Gitlab
::
Git
::
RevList
).
to
receive
(
:new
).
and_return
(
rev_list
)
expect
(
rev_list
).
to
receive
(
:new_objects
).
and_return
([])
subject
.
new_pointers
end
end
end
describe
'#all_pointers'
,
:skip_gitaly_mock
do
it
'uses rev-list to find all objects'
do
rev_list
=
double
allow
(
Gitlab
::
Git
::
RevList
).
to
receive
(
:new
).
and_return
(
rev_list
)
allow
(
rev_list
).
to
receive
(
:all_objects
).
and_yield
([
blob_object_id
])
expect
(
Gitlab
::
Git
::
Blob
).
to
receive
(
:batch_lfs_pointers
).
with
(
project
.
repository
,
[
blob_object_id
])
subject
.
all_pointers
it
'limits new_objects using object_limit'
do
expect
(
subject
.
new_pointers
(
object_limit:
1
)).
to
eq
([])
end
end
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