Commit b6e69673 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'backport-workhorse-show-all-refs' into 'master'

Support show-all-refs for git over HTTP

See merge request gitlab-org/gitlab-ce!14834
parents 466b7763 527f87df
---
title: Support show-all-refs for git over HTTP
merge_request: 14834
author:
type: added
...@@ -16,14 +16,15 @@ module Gitlab ...@@ -16,14 +16,15 @@ module Gitlab
SECRET_LENGTH = 32 SECRET_LENGTH = 32
class << self class << self
def git_http_ok(repository, is_wiki, user, action) def git_http_ok(repository, is_wiki, user, action, show_all_refs: false)
project = repository.project project = repository.project
repo_path = repository.path_to_repo repo_path = repository.path_to_repo
params = { params = {
GL_ID: Gitlab::GlId.gl_id(user), GL_ID: Gitlab::GlId.gl_id(user),
GL_REPOSITORY: Gitlab::GlRepository.gl_repository(project, is_wiki), GL_REPOSITORY: Gitlab::GlRepository.gl_repository(project, is_wiki),
GL_USERNAME: user&.username, GL_USERNAME: user&.username,
RepoPath: repo_path RepoPath: repo_path,
ShowAllRefs: show_all_refs
} }
server = { server = {
address: Gitlab::GitalyClient.address(project.repository_storage), address: Gitlab::GitalyClient.address(project.repository_storage),
......
...@@ -268,7 +268,8 @@ describe Gitlab::Workhorse do ...@@ -268,7 +268,8 @@ describe Gitlab::Workhorse do
GL_ID: "user-#{user.id}", GL_ID: "user-#{user.id}",
GL_USERNAME: user.username, GL_USERNAME: user.username,
GL_REPOSITORY: "project-#{project.id}", GL_REPOSITORY: "project-#{project.id}",
RepoPath: repo_path RepoPath: repo_path,
ShowAllRefs: false
} }
end end
...@@ -282,7 +283,8 @@ describe Gitlab::Workhorse do ...@@ -282,7 +283,8 @@ describe Gitlab::Workhorse do
GL_ID: "user-#{user.id}", GL_ID: "user-#{user.id}",
GL_USERNAME: user.username, GL_USERNAME: user.username,
GL_REPOSITORY: "wiki-#{project.id}", GL_REPOSITORY: "wiki-#{project.id}",
RepoPath: repo_path RepoPath: repo_path,
ShowAllRefs: false
} }
end end
...@@ -324,6 +326,12 @@ describe Gitlab::Workhorse do ...@@ -324,6 +326,12 @@ describe Gitlab::Workhorse do
expect(subject).to include(gitaly_params) expect(subject).to include(gitaly_params)
end end
context 'show_all_refs enabled' do
subject { described_class.git_http_ok(repository, false, user, action, show_all_refs: true) }
it { is_expected.to include(ShowAllRefs: true) }
end
end end
context "when git_receive_pack action is passed" do context "when git_receive_pack action is passed" do
...@@ -336,6 +344,12 @@ describe Gitlab::Workhorse do ...@@ -336,6 +344,12 @@ describe Gitlab::Workhorse do
let(:action) { 'info_refs' } let(:action) { 'info_refs' }
it { expect(subject).to include(gitaly_params) } it { expect(subject).to include(gitaly_params) }
context 'show_all_refs enabled' do
subject { described_class.git_http_ok(repository, false, user, action, show_all_refs: true) }
it { is_expected.to include(ShowAllRefs: true) }
end
end end
context 'when action passed is not supported by Gitaly' do context 'when action passed is not supported by Gitaly' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment