Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/gitaly_client/commit_service.rb')
-rw-r--r--lib/gitlab/gitaly_client/commit_service.rb43
1 files changed, 38 insertions, 5 deletions
diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb
index b894207f0aa..fa616a252e4 100644
--- a/lib/gitlab/gitaly_client/commit_service.rb
+++ b/lib/gitlab/gitaly_client/commit_service.rb
@@ -111,17 +111,22 @@ module Gitlab
nil
end
- def tree_entries(repository, revision, path, recursive)
+ def tree_entries(repository, revision, path, recursive, pagination_params)
request = Gitaly::GetTreeEntriesRequest.new(
repository: @gitaly_repo,
revision: encode_binary(revision),
path: path.present? ? encode_binary(path) : '.',
- recursive: recursive
+ recursive: recursive,
+ pagination_params: pagination_params
)
+ request.sort = Gitaly::GetTreeEntriesRequest::SortBy::TREES_FIRST if pagination_params
response = GitalyClient.call(@repository.storage, :commit_service, :get_tree_entries, request, timeout: GitalyClient.medium_timeout)
- response.flat_map do |message|
+ cursor = nil
+
+ entries = response.flat_map do |message|
+ cursor = message.pagination_cursor if message.pagination_cursor
message.entries.map do |gitaly_tree_entry|
Gitlab::Git::Tree.new(
id: gitaly_tree_entry.oid,
@@ -135,6 +140,8 @@ module Gitlab
)
end
end
+
+ [entries, cursor]
end
def commit_count(ref, options = {})
@@ -248,16 +255,42 @@ module Gitlab
consume_commits_response(response)
end
- def list_commits(revisions)
+ def list_commits(revisions, reverse: false)
request = Gitaly::ListCommitsRequest.new(
repository: @gitaly_repo,
- revisions: Array.wrap(revisions)
+ revisions: Array.wrap(revisions),
+ reverse: reverse
)
response = GitalyClient.call(@repository.storage, :commit_service, :list_commits, request, timeout: GitalyClient.medium_timeout)
consume_commits_response(response)
end
+ # List all commits which are new in the repository. If commits have been pushed into the repo
+ def list_new_commits(revisions, allow_quarantine: false)
+ git_env = Gitlab::Git::HookEnv.all(@gitaly_repo.gl_repository)
+ if allow_quarantine && git_env['GIT_OBJECT_DIRECTORY_RELATIVE'].present?
+ # If we have a quarantine environment, then we can optimize the check
+ # by doing a ListAllCommitsRequest. Instead of walking through
+ # references, we just walk through all quarantined objects, which is
+ # a lot more efficient. To do so, we throw away any alternate object
+ # directories, which point to the main object directory of the
+ # repository, and only keep the object directory which points into
+ # the quarantine object directory.
+ quarantined_repo = @gitaly_repo.dup
+ quarantined_repo.git_alternate_object_directories = Google::Protobuf::RepeatedField.new(:string)
+
+ request = Gitaly::ListAllCommitsRequest.new(
+ repository: quarantined_repo
+ )
+
+ response = GitalyClient.call(@repository.storage, :commit_service, :list_all_commits, request, timeout: GitalyClient.medium_timeout)
+ consume_commits_response(response)
+ else
+ list_commits(Array.wrap(revisions) + %w[--not --all])
+ end
+ end
+
def list_commits_by_oid(oids)
return [] if oids.empty?