When an object is not mapped to another already, it should be looked differently than if has already been mapped. It is not possible to use the Get() method in both cases.
If user 111 is mirrored from GitLab to the Forgejo user 888:
- First mirror: Get() cannot lookup using 111 as an ID because it may already be used by another user
- Second mirror: the user ID is mapped from 111 to 888, Get() must lookup using 888 to update the user.
There is no way for Get() to differentiate between the two.
When there is no mapping for an object ID, instead of doing nothing, the GetLocalMatchingRemote() function is called and given the object from the origin. If it finds an ID, it is set so that a subsequent Get() will use it. The modified logic is:
If user 111 is mirrored from GitLab to the Forgejo user 888:
- First mirror: GetLocalMatchingRemote() will finds that LoginName 111 for the LoginSource Gitlab is user 888
- Second mirror: the user ID is mapped from 111 to 888, Get() lookup 888 to update the user.