summaryrefslogtreecommitdiff
path: root/app/models/namespace.rb
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-02-28 20:36:07 +0100
committerKamil Trzciński <ayufan@ayufan.eu>2018-02-28 20:36:07 +0100
commite3fafa7632e038927085cf8c8228c93be44b36bd (patch)
tree4fba0d291e945415b0f0eddd40c615cd6cd70013 /app/models/namespace.rb
parente0401df1214397626e65e58166988fe62715d372 (diff)
parentf2f58a60b76acd479e37bdbc9246ec9f9b2bea82 (diff)
downloadgitlab-ce-e3fafa7632e038927085cf8c8228c93be44b36bd.tar.gz
Merge commit 'f2f58a60b76acd479e37bdbc9246ec9f9b2bea82' into object-storage-ee-to-ce-backport
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 4672881e220..4d401e7ba18 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -36,7 +36,7 @@ class Namespace < ActiveRecord::Base
validates :path,
presence: true,
length: { maximum: 255 },
- dynamic_path: true
+ namespace_path: true
validate :nesting_level_allowed
@@ -162,6 +162,13 @@ class Namespace < ActiveRecord::Base
.base_and_ancestors
end
+ # returns all ancestors upto but excluding the the given namespace
+ # when no namespace is given, all ancestors upto the top are returned
+ def ancestors_upto(top = nil)
+ Gitlab::GroupHierarchy.new(self.class.where(id: id))
+ .ancestors(upto: top)
+ end
+
def self_and_ancestors
return self.class.where(id: id) unless parent_id