summaryrefslogtreecommitdiff
path: root/app/models/namespace.rb
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2017-12-08 17:42:43 +0000
committerDouwe Maan <douwe@gitlab.com>2017-12-08 17:42:43 +0000
commit562fb460b83502c060cd84b1627dc33098e01c31 (patch)
tree36d354ef789c26146f29a00400c240b76f5c02ca /app/models/namespace.rb
parent8730054683c00f4c79cf452beef0df794c70bf6b (diff)
downloadgitlab-ce-562fb460b83502c060cd84b1627dc33098e01c31.tar.gz
Allow git pull/push on project redirects
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 901dbf2ba69..0ff169d4531 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -40,6 +40,7 @@ class Namespace < ActiveRecord::Base
namespace_path: true
validate :nesting_level_allowed
+ validate :allowed_path_by_redirects
delegate :name, to: :owner, allow_nil: true, prefix: true
@@ -257,4 +258,14 @@ class Namespace < ActiveRecord::Base
Namespace.where(id: descendants.select(:id))
.update_all(share_with_group_lock: true)
end
+
+ def allowed_path_by_redirects
+ return if path.nil?
+
+ errors.add(:path, "#{path} has been taken before. Please use another one") if namespace_previously_created_with_same_path?
+ end
+
+ def namespace_previously_created_with_same_path?
+ RedirectRoute.permanent.exists?(path: path)
+ end
end