2017-08-24 21:30:12 -04:00
|
|
|
module Gitlab
|
|
|
|
module Git
|
|
|
|
class LfsChanges
|
|
|
|
def initialize(repository, newrev)
|
|
|
|
@repository = repository
|
|
|
|
@newrev = newrev
|
|
|
|
end
|
|
|
|
|
|
|
|
def new_pointers(object_limit: nil, not_in: nil)
|
2018-02-06 17:49:33 -05:00
|
|
|
@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
|
|
|
|
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)
|
2017-08-24 21:30:12 -04:00
|
|
|
@new_pointers ||= begin
|
2017-11-03 10:33:06 -04:00
|
|
|
rev_list.new_objects(not_in: not_in, require_path: true) do |object_ids|
|
|
|
|
object_ids = object_ids.take(object_limit) if object_limit
|
2017-08-24 21:30:12 -04:00
|
|
|
|
2017-11-03 10:33:06 -04:00
|
|
|
Gitlab::Git::Blob.batch_lfs_pointers(@repository, object_ids)
|
|
|
|
end
|
2017-08-24 21:30:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-06 17:49:33 -05:00
|
|
|
def git_all_pointers
|
2018-06-07 11:49:01 -04:00
|
|
|
params = { require_path: true }
|
|
|
|
|
|
|
|
if Gitlab::Git.version >= Gitlab::VersionInfo.parse('2.16.0')
|
|
|
|
params[:options] = ["--filter=blob:limit=#{Gitlab::Git::Blob::LFS_POINTER_MAX_SIZE}"]
|
|
|
|
end
|
2018-06-06 15:07:31 -04:00
|
|
|
|
|
|
|
rev_list.all_objects(params) do |object_ids|
|
2017-11-03 10:33:06 -04:00
|
|
|
Gitlab::Git::Blob.batch_lfs_pointers(@repository, object_ids)
|
|
|
|
end
|
2017-08-24 21:30:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def rev_list
|
2018-01-31 14:25:38 -05:00
|
|
|
Gitlab::Git::RevList.new(@repository, newrev: @newrev)
|
2017-08-24 21:30:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|