diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-15 18:08:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-15 18:08:26 +0300 |
commit | 4279dbc29c63f614e6439e104204165ff0517a59 (patch) | |
tree | a2a2dc637398f9c66eeda39ee9e3e209370a84c4 /app/models/group.rb | |
parent | 7912017a137da35c48071a048c99d27737c29f0f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/group.rb')
-rw-r--r-- | app/models/group.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index f33b4fe2942..098116ed800 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -467,9 +467,10 @@ class Group < Namespace end # Check if user is a last owner of the group. + # Excludes non-direct owners for top-level group # Excludes project_bots def last_owner?(user) - has_owner?(user) && all_owners_excluding_project_bots.size == 1 + has_owner?(user) && member_owners_excluding_project_bots.size == 1 end def member_last_owner?(member) @@ -478,8 +479,14 @@ class Group < Namespace last_owner?(member.user) end - def all_owners_excluding_project_bots - members_with_parents.owners.merge(User.without_project_bot) + # Excludes non-direct owners for top-level group + # Excludes project_bots + def member_owners_excluding_project_bots + if root? + members + else + members_with_parents + end.owners.merge(User.without_project_bot) end def single_blocked_owner? @@ -489,7 +496,7 @@ class Group < Namespace def member_last_blocked_owner?(member) return member.last_blocked_owner unless member.last_blocked_owner.nil? - return false if members_with_parents.owners.any? + return false if member_owners_excluding_project_bots.any? single_blocked_owner? && blocked_owners.exists?(user_id: member.user) end |