Handle old usernames that are substrings of new usernames
What does this MR do and why?
This change addresses the bug whereby the gsub!
method originally used replaced matching substrings with the new username resulting in incorrect new username display.
For example, with the following username mapping:
'bob' => 'alice-gdk',
'alice' => 'bob-gdk'
Any instances of @bob
would be replaced with @alice-gdk
but then the alice
part of @alice-gdk
would be replaced with bob-gdk
resulting in @bob-gdk-gdk
.
Fun times
It also handles cases where usernames are interchanged between source and destination instance, e.g.:
'manuelgrabowski-admin' => 'manuelgrabowski',
'manuelgrabowski' => 'manuelgrabowski-admin'
This would previously result in @manuelgrabowski-admin
being replaced by @manuelgrabowski
, but then @manuelgrabowski
being replaced by @manuelgrabowski-admin
resulting effectively in no substitution at all.
The changes here now pass the mapped_username
hash to the .gsub!
method, along with a regex based off it, to match exact strings in a single/atomic operation (props to @manuelgrabowski for the suggestion).
Specs have been added.
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.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #413623 (closed)