summaryrefslogtreecommitdiff
path: root/app/presenters/ci/build_runner_presenter.rb
diff options
context:
space:
mode:
authorKrasimir Angelov <kangelov@gitlab.com>2019-05-30 18:40:53 +1200
committerFabio Pitino <fpitino@gitlab.com>2019-06-06 09:21:18 +0100
commitad9ae16d8a44dd2523bd6e6109db9fe2da45d3a5 (patch)
treeee8445389c89b4c7f5cc71c3d35f469345a5016f /app/presenters/ci/build_runner_presenter.rb
parent3fd99b4e7a58843943ade87a3658d477278aa412 (diff)
downloadgitlab-ce-ad9ae16d8a44dd2523bd6e6109db9fe2da45d3a5.tar.gz
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
Diffstat (limited to 'app/presenters/ci/build_runner_presenter.rb')
-rw-r--r--app/presenters/ci/build_runner_presenter.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/app/presenters/ci/build_runner_presenter.rb b/app/presenters/ci/build_runner_presenter.rb
index 6d46e0bf18a..471b6d3b726 100644
--- a/app/presenters/ci/build_runner_presenter.rb
+++ b/app/presenters/ci/build_runner_presenter.rb
@@ -25,14 +25,16 @@ module Ci
end
def git_depth
- strong_memoize(:git_depth) do
- git_depth = variables&.find { |variable| variable[:key] == 'GIT_DEPTH' }&.dig(:value)
- git_depth.to_i
- end
+ if git_depth_variable
+ git_depth_variable[:value]
+ else
+ project.default_git_depth
+ end.to_i
end
def refspecs
specs = []
+ specs << refspec_for_merge_request_ref if merge_request_ref?
if git_depth > 0
specs << refspec_for_branch(ref) if branch? || legacy_detached_merge_request_pipeline?
@@ -42,8 +44,6 @@ module Ci
specs << refspec_for_tag
end
- specs << refspec_for_merge_request_ref if merge_request_ref?
-
specs
end
@@ -89,5 +89,11 @@ module Ci
def refspec_for_merge_request_ref
"+#{ref}:#{ref}"
end
+
+ def git_depth_variable
+ strong_memoize(:git_depth_variable) do
+ variables&.find { |variable| variable[:key] == 'GIT_DEPTH' }
+ end
+ end
end
end