diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-07 15:25:42 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-07 15:25:42 +0300 |
commit | 411070c3afa621a0bdc741617c1d17f54205b81a (patch) | |
tree | 66e77bbc7d2fe55ecdb22c8b166dc0369a60aed0 /lib | |
parent | f996f7e006b206ad6505dd1edd740fa142dbcb21 (diff) | |
parent | 5c748a0bd9665c2036340d3f2b475df013810e62 (diff) |
Merge branch 'ce-rd-gitaly-client-for-list-new-objects-rpc' into 'master'
Backport of gitlab-ee!6767
See merge request gitlab-org/gitlab-ce!21037
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/checks/lfs_integrity.rb | 5 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 11 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/ref_service.rb | 17 |
3 files changed, 30 insertions, 3 deletions
diff --git a/lib/gitlab/checks/lfs_integrity.rb b/lib/gitlab/checks/lfs_integrity.rb index f0e5773ec3c..b816a8f00cd 100644 --- a/lib/gitlab/checks/lfs_integrity.rb +++ b/lib/gitlab/checks/lfs_integrity.rb @@ -1,8 +1,6 @@ module Gitlab module Checks class LfsIntegrity - REV_LIST_OBJECT_LIMIT = 2_000 - def initialize(project, newrev) @project = project @newrev = newrev @@ -11,7 +9,8 @@ module Gitlab def objects_missing? return false unless @newrev && @project.lfs_enabled? - new_lfs_pointers = Gitlab::Git::LfsChanges.new(@project.repository, @newrev).new_pointers(object_limit: REV_LIST_OBJECT_LIMIT) + new_lfs_pointers = Gitlab::Git::LfsChanges.new(@project.repository, @newrev) + .new_pointers(object_limit: ::Gitlab::Git::Repository::REV_LIST_COMMIT_LIMIT) return false unless new_lfs_pointers.present? diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 73151e4a4c5..de189ac6dfc 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -19,6 +19,7 @@ module Gitlab GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE ].freeze SEARCH_CONTEXT_LINES = 3 + REV_LIST_COMMIT_LIMIT = 2_000 # In https://gitlab.com/gitlab-org/gitaly/merge_requests/698 # We copied these two prefixes into gitaly-go, so don't change these # or things will break! (REBASE_WORKTREE_PREFIX and SQUASH_WORKTREE_PREFIX) @@ -380,6 +381,16 @@ module Gitlab end end + def new_blobs(newrev) + return [] if newrev == ::Gitlab::Git::BLANK_SHA + + strong_memoize("new_blobs_#{newrev}") do + wrapped_gitaly_errors do + gitaly_ref_client.list_new_blobs(newrev, REV_LIST_COMMIT_LIMIT) + end + end + end + def count_commits(options) options = process_count_commits_options(options.dup) diff --git a/lib/gitlab/gitaly_client/ref_service.rb b/lib/gitlab/gitaly_client/ref_service.rb index 41d58192818..8acc22e809e 100644 --- a/lib/gitlab/gitaly_client/ref_service.rb +++ b/lib/gitlab/gitaly_client/ref_service.rb @@ -82,6 +82,23 @@ module Gitlab commits end + def list_new_blobs(newrev, limit = 0) + request = Gitaly::ListNewBlobsRequest.new( + repository: @gitaly_repo, + commit_id: newrev, + limit: limit + ) + + response = GitalyClient + .call(@storage, :ref_service, :list_new_blobs, request, timeout: GitalyClient.medium_timeout) + + response.flat_map do |msg| + # Returns an Array of Gitaly::NewBlobObject objects + # Available methods are: #size, #oid and #path + msg.new_blob_objects + end + end + def count_tag_names tag_names.count end |