diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-01 03:09:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-01 03:09:44 +0300 |
commit | 83e25d14371953c18ac41b3a0cc27aadefd9bc69 (patch) | |
tree | 69d4b7cc955c7a7c414baf4e60d53ad6f5647732 /app/services/groups | |
parent | 5376a0c41d6264e6cc820b5d12220ae4ff79f2ae (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/groups')
-rw-r--r-- | app/services/groups/update_service.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/app/services/groups/update_service.rb b/app/services/groups/update_service.rb index df6ede87ef9..6e68cff6fa6 100644 --- a/app/services/groups/update_service.rb +++ b/app/services/groups/update_service.rb @@ -21,7 +21,7 @@ module Groups return false unless valid_share_with_group_lock_change? - return false unless valid_path_change_with_npm_packages? + return false unless valid_path_change? return false unless update_shared_runners @@ -46,6 +46,29 @@ module Groups private + def valid_path_change? + unless Feature.enabled?(:npm_package_registry_fix_group_path_validation) + return valid_path_change_with_npm_packages? + end + + return true unless group.packages_feature_enabled? + return true if params[:path].blank? + return true if group.has_parent? + return true if !group.has_parent? && group.path == params[:path] + + # we have a path change on a root group: + # check that we don't have any npm package with a scope set to the group path + npm_packages = ::Packages::GroupPackagesFinder.new(current_user, group, package_type: :npm, preload_pipelines: false) + .execute + .with_npm_scope(group.path) + + return true unless npm_packages.exists? + + group.errors.add(:path, s_('GroupSettings|cannot change when group contains projects with NPM packages')) + false + end + + # TODO: delete this function along with npm_package_registry_fix_group_path_validation def valid_path_change_with_npm_packages? return true unless group.packages_feature_enabled? return true if params[:path].blank? |