Commit 748c9552 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'add-ff-for-project-git-depth' into 'master'

Move project default git depth behind feature flags

Closes #62906

See merge request gitlab-org/gitlab-ce!29346
parents 9254b5d4 3df74a40
...@@ -31,6 +31,8 @@ class ProjectCiCdSetting < ApplicationRecord ...@@ -31,6 +31,8 @@ class ProjectCiCdSetting < ApplicationRecord
private private
def set_default_git_depth def set_default_git_depth
return unless Feature.enabled?(:ci_set_project_default_git_depth, default_enabled: true)
self.default_git_depth ||= DEFAULT_GIT_DEPTH self.default_git_depth ||= DEFAULT_GIT_DEPTH
end end
end end
...@@ -27,7 +27,7 @@ module Ci ...@@ -27,7 +27,7 @@ module Ci
def git_depth def git_depth
if git_depth_variable if git_depth_variable
git_depth_variable[:value] git_depth_variable[:value]
else elsif Feature.enabled?(:ci_project_git_depth, default_enabled: true)
project.default_git_depth project.default_git_depth
end.to_i end.to_i
end end
......
...@@ -48,5 +48,17 @@ describe ProjectCiCdSetting do ...@@ -48,5 +48,17 @@ describe ProjectCiCdSetting do
expect(project.reload.ci_cd_settings.default_git_depth).to eq(0) expect(project.reload.ci_cd_settings.default_git_depth).to eq(0)
end end
context 'when feature flag :ci_set_project_default_git_depth is disabled' do
let(:project) { create(:project) }
before do
stub_feature_flags(ci_set_project_default_git_depth: { enabled: false } )
end
it 'does not set default value for new records' do
expect(project.ci_cd_settings.default_git_depth).to eq(nil)
end
end
end end
end end
...@@ -136,6 +136,16 @@ describe Ci::BuildRunnerPresenter do ...@@ -136,6 +136,16 @@ describe Ci::BuildRunnerPresenter do
it 'defaults to git depth setting for the project' do it 'defaults to git depth setting for the project' do
expect(git_depth).to eq(build.project.default_git_depth) expect(git_depth).to eq(build.project.default_git_depth)
end end
context 'when feature flag :ci_project_git_depth is disabled' do
before do
stub_feature_flags(ci_project_git_depth: { enabled: false })
end
it 'defaults to 0' do
expect(git_depth).to eq(0)
end
end
end end
describe '#refspecs' do describe '#refspecs' 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