From ad9ae16d8a44dd2523bd6e6109db9fe2da45d3a5 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Thu, 30 May 2019 18:40:53 +1200 Subject: Add project level git depth setting Introduce default_git_depth in project's CI/CD settings and set it to 50. Use it if there is no GIT_DEPTH variable specified. Apply this default only to newly created projects and keep it nil for old ones in order to not break pipelines that rely on non-shallow clones. default_git_depth can be updated from CI/CD Settings in the UI, must be either nil or integer between 0 and 1000 (incl). Inherit default_git_depth from the origin project when forking projects. MR pipelines are run on a MR ref (refs/merge-requests/:iid/merge) and it contains unique commit (i.e. merge commit) which doesn't exist in the other branch/tags refs. We need to add it cause otherwise it may break pipelines for old projects that have already enabled Pipelines for merge results and have git depth 0. Document new default_git_depth project CI/CD setting --- .../projects/settings/ci_cd_controller_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'spec/controllers/projects') diff --git a/spec/controllers/projects/settings/ci_cd_controller_spec.rb b/spec/controllers/projects/settings/ci_cd_controller_spec.rb index b91a4df40a5..117b9cf7915 100644 --- a/spec/controllers/projects/settings/ci_cd_controller_spec.rb +++ b/spec/controllers/projects/settings/ci_cd_controller_spec.rb @@ -200,6 +200,21 @@ describe Projects::Settings::CiCdController do expect(response).to redirect_to(namespace_project_settings_ci_cd_path) end end + + context 'when default_git_depth is not specified' do + let(:params) { { ci_cd_settings_attributes: { default_git_depth: 10 } } } + + before do + project.ci_cd_settings.update!(default_git_depth: nil) + end + + it 'set specified git depth' do + subject + + project.reload + expect(project.default_git_depth).to eq(10) + end + end end end end -- cgit v1.2.1