Skip to content

Bitbucket Server - Map contributions to namespace user for imports into personal namespaces

What does this MR do and why?

This MR updates the Bitbucket Server importer so that when a project is imported into a personal user namespace, all user contributions are assigned to the personal namespace owner. Because personal namespaces don't have memberships like groups, there's no way for a user to reassign placeholder users via the UI. Plus, user contribution mapping isn't supported in personal namespaces, so it's simpler to immediately map contributions to the namespace owner.

It also introduces a new feature flag user_mapping_to_personal_namespace_owner that does a few things:

  • allows this change to be implemented in each importer in separately instead of one huge MR
  • prevents contributions from in-progress imports from being partially assigned to the import user and partially to the namespace owner
Notable technical decisions
  • User contributions imported to personal namespaces are mapped to the namespace owner, not current_user (importing user). The only users who can import into a personal namespace are the namespace owner, or an admin (see user_namespace_policy). If an admin were to import a project into another user's personal namespace, it wouldn't make sense to map those contributions to the admin.
  • Similarly, there's no current_user == namespace.owner_id. If this check was implemented before mapping to the namespace owner and an admin imports into a personal user namespace, the fallback would most likely be mapping contributions to the import user, which runs into the original problem.
  • Mapping to the namespace owner when importing to a personal namespace is disabled when user contribution mapping is disabled to preserve existing behavior when user mapping is disabled.
  • UI warning to users has not been updated yet since this is only available for Bitbucket Server imports and the flag isn't intended to be rolled out until it's implemented in all project importers.

References

Related to #525342 (closed)

Screenshots or screen recordings

Destination type Before After
Personal namespace image user_mapping_to_personal_namespace_owner enabled:
image
user_mapping_to_personal_namespace_owner disabled: image
Group image user_mapping_to_personal_namespace_owner enabled (no effect):
image

How to set up and validate locally

  1. Enable user_mapping_to_personal_namespace_owner
  2. Ensure you have access to a Bitbucket server repository with user contributions. See how to set up Bitbucket Server locally and import from Bitbucket Server docs
  3. Import a project from a Bitbucket server instance into a personal namespace
  4. Verify that all user contributions have been mapped to the namespace owner
  5. Import the project to group
  6. Verify that placeholder users were created and user mapping is unaffected

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #525342 (closed)

Edited by Sam Word

Merge request reports

Loading