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
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/commit.rb5
-rw-r--r--lib/gitlab/gitaly_client.rb16
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index 89f761dd515..f24ebe8a7d2 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -60,6 +60,11 @@ module Gitlab
# Some weird thing?
return nil unless commit_id.is_a?(String)
+ # The Go-Git backend Gitaly might use, tries to be nice when resolving
+ # to the commit, and `master:ref` will resolve to the commit that master
+ # resolves to. To keep behaviour the same, we return nil
+ return nil if commit_id.include?(':')
+
commit = repo.gitaly_migrate(:find_commit) do |is_enabled|
if is_enabled
repo.gitaly_commit_client.find_commit(commit_id)
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb
index 550294916a4..52e940ee407 100644
--- a/lib/gitlab/gitaly_client.rb
+++ b/lib/gitlab/gitaly_client.rb
@@ -191,6 +191,8 @@ module Gitlab
metadata['call_site'] = feature.to_s if feature
metadata['gitaly-servers'] = address_metadata(remote_storage) if remote_storage
+ metadata.merge!(server_feature_flags(feature))
+
result = { metadata: metadata }
# nil timeout indicates that we should use the default
@@ -209,6 +211,20 @@ module Gitlab
result
end
+ SERVER_FEATURE_FLAGS = {
+ find_commit: ["gogit-findcommit"]
+ }.freeze
+
+ # Other than data on the disk, Gitaly is stateless. Rails will thus set
+ # feature flags in the request metadata.
+ def self.server_feature_flags(feature)
+ return {} unless SERVER_FEATURE_FLAGS.key?(feature)
+
+ SERVER_FEATURE_FLAGS[feature]
+ .map { |f| ["gitaly-feature-#{f}", feature_enabled?(f).to_s] }
+ .to_h
+ end
+
def self.token(storage)
params = Gitlab.config.repositories.storages[storage]
raise "storage not found: #{storage.inspect}" if params.nil?