summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-06-29 23:26:23 -0700
committerStan Hu <stanhu@gmail.com>2017-06-30 07:21:01 -0700
commit9c8075c4b95f090fc6f00c897f6bf097d29ee8bf (patch)
tree462dc0ec31326675e60b67a7d3bb8351ef73e70f /app/models
parent5a983ac431affc800d5e9db9e83c14710ec29c36 (diff)
downloadgitlab-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.rb20
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?