Commit 7d04effb authored by Son Luong Ngoc's avatar Son Luong Ngoc Committed by James Fargher

Decouple partial clone config

Previously partial clone configs is coupled with receive_max_input_size
check. This make sense when you think of partial clone as a replacement
for Git LFS but in truth, the 2 features are separated and should not be
 decoupled.

In self-managing instances, `receive_max_input_size` could be set to 0
while users could still wish to have partial clone feature enabled.

References:
- [Original discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/16850#note_313323533)
- [Tracking issue](https://gitlab.com/gitlab-org/gitlab/-/issues/212926)
parent 7ba626ab
---
title: Decouple partial clone config from max input size
merge_request: 30354
author: Son Luong Ngoc
type: changed
......@@ -69,13 +69,14 @@ module API
}
# Custom option for git-receive-pack command
if Feature.enabled?(:gitaly_upload_pack_filter, project, default_enabled: true)
payload[:git_config_options] << "uploadpack.allowFilter=true" << "uploadpack.allowAnySHA1InWant=true"
end
receive_max_input_size = Gitlab::CurrentSettings.receive_max_input_size.to_i
if receive_max_input_size > 0
payload[:git_config_options] << "receive.maxInputSize=#{receive_max_input_size.megabytes}"
if Feature.enabled?(:gitaly_upload_pack_filter, project, default_enabled: true)
payload[:git_config_options] << "uploadpack.allowFilter=true" << "uploadpack.allowAnySHA1InWant=true"
end
end
response_with_status(**payload)
......
......@@ -441,10 +441,11 @@ describe API::Internal::Base do
allow(Gitlab::CurrentSettings).to receive(:receive_max_input_size) { 1 }
end
it 'returns custom git config' do
it 'returns maxInputSize and partial clone git config' do
push(key, project)
expect(json_response["git_config_options"]).to be_present
expect(json_response["git_config_options"]).to include("receive.maxInputSize=1048576")
expect(json_response["git_config_options"]).to include("uploadpack.allowFilter=true")
expect(json_response["git_config_options"]).to include("uploadpack.allowAnySHA1InWant=true")
end
......@@ -454,10 +455,11 @@ describe API::Internal::Base do
stub_feature_flags(gitaly_upload_pack_filter: { enabled: false, thing: project })
end
it 'does not include allowFilter and allowAnySha1InWant in the git config options' do
it 'returns only maxInputSize and not partial clone git config' do
push(key, project)
expect(json_response["git_config_options"]).to be_present
expect(json_response["git_config_options"]).to include("receive.maxInputSize=1048576")
expect(json_response["git_config_options"]).not_to include("uploadpack.allowFilter=true")
expect(json_response["git_config_options"]).not_to include("uploadpack.allowAnySHA1InWant=true")
end
......@@ -465,12 +467,28 @@ describe API::Internal::Base do
end
context 'when receive_max_input_size is empty' do
it 'returns an empty git config' do
before do
allow(Gitlab::CurrentSettings).to receive(:receive_max_input_size) { nil }
end
it 'returns partial clone git config' do
push(key, project)
expect(json_response["git_config_options"]).to be_empty
expect(json_response["git_config_options"]).to be_present
expect(json_response["git_config_options"]).to include("uploadpack.allowFilter=true")
expect(json_response["git_config_options"]).to include("uploadpack.allowAnySHA1InWant=true")
end
context 'when gitaly_upload_pack_filter feature flag is disabled' do
before do
stub_feature_flags(gitaly_upload_pack_filter: { enabled: false, thing: project })
end
it 'returns an empty git config' do
push(key, project)
expect(json_response["git_config_options"]).to be_empty
end
end
end
end
......
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