Skip to content

Fix group name conflict when migrating groups via BulkImport

What does this MR do and why?

Namespaces cannot have subgroups with the same name, so when importing a group into a preexisting namespace, we need to guarantee that the imported group won't have a name that conflicts with a preexisting group.

This change modifies the BulkImports::Groups::Transformers::GroupAttributesTransformer to append a counter to the source group name in case the name conflicts with another subgroup of the namespace.

Related to: GitLab Importer fails to import when importing ... (#362954 - closed)

Describe in detail what your merge request does and why.

Screenshots or screen recordings

group-name-unique

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

  1. Feature.enable(:bulk_import).
  2. Create a top-level group with the name "Group A".
  3. Create another top-level group and create a subgroup with the name "Group A"
  4. Go to the /groups/new#import-group-pane page and enter the instance URL and access token (needs to be API & read_repository scope).
  5. Import the first top-level group into the second top-level group.
  6. Wait for group import to complete and verify that the first top-level group was imported as a subgroup in the second top-level group but with the name "Group A(1)"

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports