Skip to content

GitHub Importer - Map contributions to personal namespace owner

What does this MR do and why?

This MR updates the GitHub 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.

This MR includes refactors to how placeholder references are pushed to Redis during the import:

  • Replaced Gitlab::GithubImport::PushPlaceholderReferences with Import::PlaceholderReferences::Pusher because they were almost identical except for a few additional methods added on PushPlaceholderReferences that the Github importer needed. It also makes the user mapping implementation in the GitHub importer much more similar to its implementation in the Bitbucket Server importer, solidifying implementation patters.
  • Updated Import::PlaceholderReferences::Pusher to include the methods needed by GitHub imports
  • Removed Gitlab::GithubImport::ContributionsMapper. It was used to pass the user mapper to PushPlaceholderReferences, and in UserFinder. Now that Pusher handles instantiating SourceUserMapper, there wasn't much need to keep this class. The same feature flag checks defined on ContributionsMapper are also defined on Pusher, so they're still accessible when needed.

References

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 Github repository with user contributions. See import from GitHub docs for instructions and prerequisites
  3. Import a repository from GitHub 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