Bitbucket Cloud importer: find user by GUID if not found by username
Problem
During Bitbucket Cloud imports, it's important to assign merge requests to the matching author from Bitbucket.
Users are connected to BBC via an OAuth connection which creates an Identity record with an extern_uid
. There is a bug whereby the first the time the connection is made the extern_uid
is set to the user's username on BBC and if the connection is disabled and re-enabled, the extern_uid
is a GUID.
The extern_uid
is used to look up matching users on gitlab and the code relies on it being a username.
Proposed solution
Alter the BBC pull request importer to check if there's a corresponding BB identity with extern_uid
matching on GUID if one is not found for extern_uid
matching on username.
This will allow MR authors to be migrated correctly regardless of the extern_uid
set by the OAuth connection.
cc @erudinsky