Comment why forks get default_git_depth of 0 instead nil

and simplify ProjectCiCdSetting#set_default_git_depth
This commit is contained in:
Krasimir Angelov 2019-06-07 00:39:46 +12:00
parent c0a812ecb7
commit b8704dce72
2 changed files with 4 additions and 3 deletions

View File

@ -31,8 +31,6 @@ class ProjectCiCdSetting < ApplicationRecord
private
def set_default_git_depth
return if default_git_depth
self.default_git_depth = DEFAULT_GIT_DEPTH
self.default_git_depth ||= DEFAULT_GIT_DEPTH
end
end

View File

@ -43,6 +43,9 @@ module Projects
shared_runners_enabled: @project.shared_runners_enabled,
namespace_id: target_namespace.id,
fork_network: fork_network,
# We need to set default_git_depth to 0 for the forked project when
# @project.default_git_depth is nil in order to keep the same behaviour
# and not get ProjectCiCdSetting::DEFAULT_GIT_DEPTH set on create
ci_cd_settings_attributes: { default_git_depth: @project.default_git_depth || 0 },
# We need to assign the fork network membership after the project has
# been instantiated to avoid ActiveRecord trying to create it when