]> source.dussan.org Git - gitea.git/commitdiff
Update object repo with the migrated repository (#18684)
authorHugo Hoitink <10838836+hoitih@users.noreply.github.com>
Wed, 9 Feb 2022 19:20:44 +0000 (20:20 +0100)
committerGitHub <noreply@github.com>
Wed, 9 Feb 2022 19:20:44 +0000 (19:20 +0000)
When migrating a repository (from GitHub) using the API (**POST** `repos/migrate`), the Code Indexer is not updated. Searching in the user interface will not return any results.

When migrating the same repository using **+/New Migration** in the web interface, the search index is updated and searching works as expected.

Caused by the fact that object `repo` is never updated with the migrated repo so `setting.Indexer.RepoIndexerEnabled && !repo.IsEmpty` in `modules/notification/indexer/indexer.go:NotifyMigrateRepository` always evaluates to `false`.

Tested with gitea:1.16.1, MariaDB:10, Breve in `Run Mode: Dev`.

routers/api/v1/repo/migrate.go

index 394504a99d20827996849c7afed6a8543aab2ac3..26da835546e629865d45d2e5f940fa0be0623171 100644 (file)
@@ -203,7 +203,7 @@ func Migrate(ctx *context.APIContext) {
                }
        }()
 
-       if _, err = migrations.MigrateRepository(graceful.GetManager().HammerContext(), ctx.User, repoOwner.Name, opts, nil); err != nil {
+       if repo, err = migrations.MigrateRepository(graceful.GetManager().HammerContext(), ctx.User, repoOwner.Name, opts, nil); err != nil {
                handleMigrateError(ctx, repoOwner, remoteAddr, err)
                return
        }