diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-09 18:11:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-09 18:11:31 +0300 |
commit | 283318c20561cc040b62397060771efa74db0d90 (patch) | |
tree | 31b724e53806352b1bff5e1e460e6f4445c4e0a0 /app/finders | |
parent | 1f229cdc22b5b32989bcff2037d8925c75703671 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/groups/accepting_project_transfers_finder.rb | 43 | ||||
-rw-r--r-- | app/finders/groups/user_groups_finder.rb | 2 | ||||
-rw-r--r-- | app/finders/repositories/changelog_tag_finder.rb | 4 |
3 files changed, 46 insertions, 3 deletions
diff --git a/app/finders/groups/accepting_project_transfers_finder.rb b/app/finders/groups/accepting_project_transfers_finder.rb new file mode 100644 index 00000000000..09d3c430641 --- /dev/null +++ b/app/finders/groups/accepting_project_transfers_finder.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Groups + class AcceptingProjectTransfersFinder + def initialize(current_user) + @current_user = current_user + end + + def execute + if Feature.disabled?(:include_groups_from_group_shares_in_project_transfer_locations) + return current_user.manageable_groups + end + + groups_accepting_project_transfers = + [ + current_user.manageable_groups, + managable_groups_originating_from_group_shares + ] + + groups = ::Group.from_union(groups_accepting_project_transfers) + + groups.project_creation_allowed + end + + private + + attr_reader :current_user + + def managable_groups_originating_from_group_shares + GroupGroupLink + .with_owner_or_maintainer_access + .groups_accessible_via( + groups_that_user_has_owner_or_maintainer_access_via_direct_membership + .select(:id) + ) + end + + def groups_that_user_has_owner_or_maintainer_access_via_direct_membership + # Only maintainers or above in a group has access to transfer projects to that group + current_user.owned_or_maintainers_groups + end + end +end diff --git a/app/finders/groups/user_groups_finder.rb b/app/finders/groups/user_groups_finder.rb index c77599530df..bda8b7cc1e0 100644 --- a/app/finders/groups/user_groups_finder.rb +++ b/app/finders/groups/user_groups_finder.rb @@ -48,7 +48,7 @@ module Groups if permission_scope_create_projects? target_user.manageable_groups(include_groups_with_developer_maintainer_access: true) elsif permission_scope_transfer_projects? - target_user.manageable_groups(include_groups_with_developer_maintainer_access: false) + Groups::AcceptingProjectTransfersFinder.new(target_user).execute # rubocop: disable CodeReuse/Finder else target_user.groups end diff --git a/app/finders/repositories/changelog_tag_finder.rb b/app/finders/repositories/changelog_tag_finder.rb index 3c110e6c65d..7dd7404730f 100644 --- a/app/finders/repositories/changelog_tag_finder.rb +++ b/app/finders/repositories/changelog_tag_finder.rb @@ -37,14 +37,14 @@ module Repositories begin regex = Gitlab::UntrustedRegexp.new(@regex) - rescue RegexpError => ex + rescue RegexpError => e # The error messages produced by default are not very helpful, so we # raise a better one here. We raise the specific error here so its # message is displayed in the API (where we catch this specific # error). raise( Gitlab::Changelog::Error, - "The regular expression to use for finding the previous tag for a version is invalid: #{ex.message}" + "The regular expression to use for finding the previous tag for a version is invalid: #{e.message}" ) end |