migrations: Map non-existant external users to Ghost
When performing migrations, and need to remap external users to local ones, when no local mapping is possible, map the external user to Ghost, rather than the user who initiated the migration. Mapping the external user to the migration initiator has the potential of breaking assumptions elsewhere, like only having one review per pull request per user. Mapping these migrated, locally unavailable users to Ghost makes sure these - often hidden - assumptions do not break. Fixes #3860. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
parent
95ccbb5995
commit
ade7304eea
3 changed files with 8 additions and 7 deletions
|
@ -145,24 +145,24 @@ func TestGiteaUploadRemapLocalUser(t *testing.T) {
|
|||
|
||||
//
|
||||
// The externalID does not match any existing user, everything
|
||||
// belongs to the doer
|
||||
// belongs to the Ghost user
|
||||
//
|
||||
target := repo_model.Release{}
|
||||
uploader.userMap = make(map[int64]int64)
|
||||
err := uploader.remapUser(&source, &target)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, doer.ID, target.GetUserID())
|
||||
assert.EqualValues(t, user_model.GhostUserID, target.GetUserID())
|
||||
|
||||
//
|
||||
// The externalID matches a known user but the name does not match,
|
||||
// everything belongs to the doer
|
||||
// everything belongs to the Ghost user
|
||||
//
|
||||
source.PublisherID = user.ID
|
||||
target = repo_model.Release{}
|
||||
uploader.userMap = make(map[int64]int64)
|
||||
err = uploader.remapUser(&source, &target)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, doer.ID, target.GetUserID())
|
||||
assert.EqualValues(t, user_model.GhostUserID, target.GetUserID())
|
||||
|
||||
//
|
||||
// The externalID and externalName match an existing user, everything
|
||||
|
@ -195,13 +195,13 @@ func TestGiteaUploadRemapExternalUser(t *testing.T) {
|
|||
|
||||
//
|
||||
// When there is no user linked to the external ID, the migrated data is authored
|
||||
// by the doer
|
||||
// by the Ghost user
|
||||
//
|
||||
uploader.userMap = make(map[int64]int64)
|
||||
target := repo_model.Release{}
|
||||
err := uploader.remapUser(&source, &target)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, doer.ID, target.GetUserID())
|
||||
assert.EqualValues(t, user_model.GhostUserID, target.GetUserID())
|
||||
|
||||
//
|
||||
// Link the external ID to an existing user
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue