Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2016-06-23 00:04:51 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2016-06-30 05:30:31 +0300
commit86359ec854314574dccea75247f45590262b05c0 (patch)
tree52aaf922e5a6fc63b0d42095322f79cdae659b43 /config/initializers/6_validations.rb
parentb32a6add8fa602eb35648f3f4661df8b98d909cb (diff)
Refactor repository paths handling to allow multiple git mount points
Diffstat (limited to 'config/initializers/6_validations.rb')
-rw-r--r--config/initializers/6_validations.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/config/initializers/6_validations.rb b/config/initializers/6_validations.rb
new file mode 100644
index 00000000000..3ba9e36c567
--- /dev/null
+++ b/config/initializers/6_validations.rb
@@ -0,0 +1,24 @@
+def storage_name_valid?(name)
+ !!(name =~ /\A[a-zA-Z0-9\-_]+\z/)
+end
+
+def find_parent_path(name, path)
+ Gitlab.config.repositories.storages.detect do |n, p|
+ name != n && path.chomp('/').start_with?(p.chomp('/'))
+ end
+end
+
+def error(message)
+ raise "#{message}. Please fix this in your gitlab.yml before starting GitLab."
+end
+
+error('No repository storage path defined') if Gitlab.config.repositories.storages.empty?
+
+Gitlab.config.repositories.storages.each do |name, path|
+ error("\"#{name}\" is not a valid storage name") unless storage_name_valid?(name)
+
+ parent_name, _parent_path = find_parent_path(name, path)
+ if parent_name
+ error("#{name} is a nested path of #{parent_name}. Nested paths are not supported for repository storages")
+ end
+end