diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-08-25 04:30:12 +0300 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-11-01 19:41:05 +0300 |
commit | fb3f9c6e507b232649757e996243e292064b32bb (patch) | |
tree | 08e39e77c7ca8f2e2d2305a286127c4bc3b66038 /lib/gitlab/git/lfs_changes.rb | |
parent | b5e7035c1a5e89845faada20addff98fdcefbd1e (diff) |
Detect changes to LFS pointers for pruning and integrity check
Gitlab::Git::Blob.batch_lfs_metadata can be used to check for LFS pointers. It uses a lazy enumorator and filters by blob size
Diffstat (limited to 'lib/gitlab/git/lfs_changes.rb')
-rw-r--r-- | lib/gitlab/git/lfs_changes.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/gitlab/git/lfs_changes.rb b/lib/gitlab/git/lfs_changes.rb new file mode 100644 index 00000000000..2749e2e69e2 --- /dev/null +++ b/lib/gitlab/git/lfs_changes.rb @@ -0,0 +1,36 @@ +module Gitlab + module Git + class LfsChanges + def initialize(repository, newrev) + @repository = repository + @newrev = newrev + end + + def new_pointers(object_limit: nil, not_in: nil) + @new_pointers ||= begin + object_ids = new_objects(not_in: not_in) + object_ids = object_ids.take(object_limit) if object_limit + + Gitlab::Git::Blob.batch_lfs_pointers(@repository, object_ids) + end + end + + def all_pointers + object_ids = rev_list.all_objects(require_path: true) + + Gitlab::Git::Blob.batch_lfs_pointers(@repository, object_ids) + end + + private + + def new_objects(not_in:) + rev_list.new_objects(require_path: true, lazy: true, not_in: not_in) + end + + def rev_list + ::Gitlab::Git::RevList.new(path_to_repo: @repository.path_to_repo, + newrev: @newrev) + end + end + end +end |