diff options
author | Stan Hu <stanhu@gmail.com> | 2017-06-29 23:26:23 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-06-30 07:21:01 -0700 |
commit | 9c8075c4b95f090fc6f00c897f6bf097d29ee8bf (patch) | |
tree | 462dc0ec31326675e60b67a7d3bb8351ef73e70f /app/models | |
parent | 5a983ac431affc800d5e9db9e83c14710ec29c36 (diff) | |
download | gitlab-ce-9c8075c4b95f090fc6f00c897f6bf097d29ee8bf.tar.gz |
Make Project#ensure_repository force create a repo
In Geo, Project#ensure_repository is used to make sure that a Git repo
is available to be fetched on a secondary. If a project were a fork,
this directory would never be created.
Closes gitlab-org/gitlab-ee#2800
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index a75c5209955..21f4a18ec4a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1073,21 +1073,21 @@ class Project < ActiveRecord::Base merge_requests.where(source_project_id: self.id) end - def create_repository + def create_repository(force = false) # Forked import is handled asynchronously - unless forked? - if gitlab_shell.add_repository(repository_storage_path, path_with_namespace) - repository.after_create - true - else - errors.add(:base, 'Failed to create repository via gitlab-shell') - false - end + return if forked? && !force + + if gitlab_shell.add_repository(repository_storage_path, path_with_namespace) + repository.after_create + true + else + errors.add(:base, 'Failed to create repository via gitlab-shell') + false end end def ensure_repository - create_repository unless repository_exists? + create_repository(true) unless repository_exists? end def repository_exists? |