diff options
author | Earl Warren <earl-warren@noreply.codeberg.org> | 2024-05-28 18:42:31 +0200 |
---|---|---|
committer | Earl Warren <earl-warren@noreply.codeberg.org> | 2024-05-28 18:42:31 +0200 |
commit | ae99aa0bbeea789f35ba6884a3b17cdac7c251fd (patch) | |
tree | e60f3a261415d39bbd4e5042b658d0fe27afae11 /services | |
parent | Merge pull request '[gitea] week 2024-22 cherry pick (gitea/main -> forgejo)'... (diff) | |
parent | migrations: Map non-existant external users to Ghost (diff) | |
download | forgejo-ae99aa0bbeea789f35ba6884a3b17cdac7c251fd.tar.xz forgejo-ae99aa0bbeea789f35ba6884a3b17cdac7c251fd.zip |
Merge pull request 'migrations: Map non-existant external users to Ghost' (#3935) from algernon/forgejo:who-let-the-nils-out into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3935
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Diffstat (limited to 'services')
-rw-r--r-- | services/migrations/gitea_uploader.go | 2 | ||||
-rw-r--r-- | services/migrations/gitea_uploader_test.go | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index 4d54de0b07..3ba4ca203b 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -996,7 +996,7 @@ func (g *GiteaLocalUploader) remapUser(source user_model.ExternalUserMigrated, t if userID > 0 { return target.RemapExternalUser("", 0, userID) } - return target.RemapExternalUser(source.GetExternalName(), source.GetExternalID(), g.doer.ID) + return target.RemapExternalUser(source.GetExternalName(), source.GetExternalID(), user_model.GhostUserID) } func (g *GiteaLocalUploader) remapLocalUser(source user_model.ExternalUserMigrated) (int64, error) { diff --git a/services/migrations/gitea_uploader_test.go b/services/migrations/gitea_uploader_test.go index e98582f31a..35da8290c8 100644 --- a/services/migrations/gitea_uploader_test.go +++ b/services/migrations/gitea_uploader_test.go @@ -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 |