Update GitHub event importers to handle user mapping
What does this MR do and why?
This is a subset of changes from the original MR to update GitHub object importers to use user contribution mapping. In this MR, only importers related to events are updated:
* lib/gitlab/github_import/importer/events/base_importer.rb
* lib/gitlab/github_import/importer/events/changed_assignee.rb
* lib/gitlab/github_import/importer/events/changed_label.rb
* lib/gitlab/github_import/importer/events/changed_milestone.rb
* lib/gitlab/github_import/importer/events/changed_reviewer.rb
* lib/gitlab/github_import/importer/events/closed.rb
* lib/gitlab/github_import/importer/events/cross_referenced.rb
* lib/gitlab/github_import/importer/events/merged.rb
* lib/gitlab/github_import/importer/events/renamed.rb
* lib/gitlab/github_import/importer/events/reopened.rb
PLEASE NOTE: The merged by
and review
events have their own importers so some events will not be updated with these changes.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- pull the branch of this MR and check out to it
- restart your gdk
- ensure the github importer is selected in Admin > Settings > General > Import and export settings
- open the rails console (
gdk rails c
) and ensure you have:github_user_mapping
and:importer_user_mapping
feature flags enabled ( eg `Feature.enabled?(:github_user_mapping) - create a project on GitHub with a Pull Request and Issue with commented, changed assignee, changed reviewer, labels, milestones, closed, reopened, cross referenced, reopened, merged events
- create a 'classic' api token on GitHub with
repo
andread:org
permission - create a group on your gdk
- select create project
- select import project
- select github
- add your GH api token where required
- select the group created and the project you want to import.
- select import
- once the import is complete check the
import_source_users_placeholder_references
DB table to confirm user references for notes have been created - open the pages for the imported Issue and Merge Request and confirm the events have been assigned to "placeholder" users.
- in the rails console, reassign a placeholder user to an existing user:
source_user = Import::SourceUser.find(ID) # Source User
user = User.find(ID) # Reassign to this user
::Import::SourceUsers::ReassignService.new(source_user, user, current_user: User.first).execute
::Import::SourceUsers::AcceptReassignmentService.new(source_user, current_user: user, reassignment_token: source_user.reassignment_token).execute
- check that the reassignment is complete. The
status
for the correspondingimport_source_user
record will be5
- once complete reload the Issue and Merge Request pages to confirm that the relevant events have now been reassigned to the correct user.
Related to #466355
Edited by Carla Drago