Gitea importer not mapping to placeholder users with feature flag enabled

Problem

Importing a project from Gitea does not map user contributions despite both the :importer_user_mapping and :gitea_user_mapping feature flags being enabled. Both Gitea and GitHub user mapping are both disabled by default on .com at the moment.

It appears to be a conflict in how we set user_contribution_mapping_enabled on a project's import_data before the import begins. The problem stems from the two importers sharing the components that set user_contribution_mapping_enabled up until Projects::ImportService starts the first importer, where the importer classes diverge:

  • First, LegacyGithubImport::ProjectCreator sets user_contribution_mapping_enabled attribute to trueby passing nested attributes for import_data. This was written before user mapping was implemented in the GitHub importer.
  • Then, [GithubImport::Settings](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/github_import/settings.rb#L57) overwrites import_data.data[user_contribution_mapping_enabled]tofalse` for Gitea imports, since it was written to check for GitHub user mapping.

Proposal

Update GithubImport::Settings to check for the presence of :gitea_user_mapping as well as github_user_mapping depending on the project import type. Because the Gitea and GitHub share these components, we should consolidate where we check for feature flags into one location so neither has the chance of being overwritten.

Edited by Sam Word