diff options
author | Krasimir Angelov <kangelov@gitlab.com> | 2019-06-06 15:39:46 +0300 |
---|---|---|
committer | Krasimir Angelov <kangelov@gitlab.com> | 2019-06-06 15:39:46 +0300 |
commit | b8704dce72fd8992b1f785c0ffa2f2c0eab81334 (patch) | |
tree | 203686a6e2c95c88857d5f71dd748d4fa715887e /app | |
parent | c0a812ecb74f1fd519d096d8be36f0a2436adc94 (diff) |
Comment why forks get default_git_depth of 0 instead nil
and simplify ProjectCiCdSetting#set_default_git_depth
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project_ci_cd_setting.rb | 4 | ||||
-rw-r--r-- | app/services/projects/fork_service.rb | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/app/models/project_ci_cd_setting.rb b/app/models/project_ci_cd_setting.rb index 9e7d921c229..492d50766ea 100644 --- a/app/models/project_ci_cd_setting.rb +++ b/app/models/project_ci_cd_setting.rb @@ -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 diff --git a/app/services/projects/fork_service.rb b/app/services/projects/fork_service.rb index f1bad2d9b15..0b4ab7b8e4d 100644 --- a/app/services/projects/fork_service.rb +++ b/app/services/projects/fork_service.rb @@ -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 |