diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-10 16:45:35 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-10 17:55:02 +0300 |
commit | 9d1348d66838b4c5e25ba133d486239482973fca (patch) | |
tree | d7c56904b3f991c462be9c593ef9e130addd1442 /app/models/project.rb | |
parent | 7611e6a0f745393aa432e4201e8053072a263c2e (diff) |
Move the `ancestors_upto` to `Project` and `Namespace`
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index a60aa28cd36..fdbc1f5d50c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -471,6 +471,13 @@ class Project < ActiveRecord::Base end end + # returns all ancestor-groups upto but excluding the given namespace + # when no namespace is given, all ancestors upto the top are returned + def ancestors_upto(top = nil) + Gitlab::GroupHierarchy.new(Group.where(id: namespace_id)) + .base_and_ancestors(upto: top) + end + def lfs_enabled? return namespace.lfs_enabled? if self[:lfs_enabled].nil? |