Repo Indexer does not work with new migrated repositories from API /repo/migrate #9634

Closed
opened 2025-11-02 08:45:02 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @Joannazyx on GitHub (Sep 29, 2022).

Description

I'm using gitea 1.15.5 with Code Search feature, with elastic search as the engine. I use a script to import some repositories from a private Gitlab by API "/repo/migrate". But after migration, these repositories fail to appear in code search results. I have to manually commit something new to the new repo to trigger report to elastic search, or delete the old elastic search topic and create a new index.
I have met this problem on websites, and reported in this issue #16986 , then follow the bugfix of this issue. So I am sure that the code index works well when migrating from UI.
But API "/repo/migrate" has a different progress from websites.
Here is my guess: In routers\api\v1\repo\migrate.go, gitea use a defer function to notify repo migrate after creating a new empty repo by function repo_module.CreateRepository. Then start a migrate task. The repo is not empty after migration, but in defer function, it still use the original "repo" param, therefore repo.IsEmpty=true, and will not trigger gitea code index to report to elastic search.
routers\api\v1\repo\migrate.go
image

In modules\notification\indexer\indexer.go Gitea only repo to index engine when repo.IsEmpty=false
image

Thanks for reading my question, look forward to your kind reply~~~

Gitea Version

1.15.5

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

kubectl

Database

MySQL

Originally created by @Joannazyx on GitHub (Sep 29, 2022). ### Description I'm using gitea 1.15.5 with Code Search feature, with elastic search as the engine. I use a script to import some repositories from a private Gitlab by API "/repo/migrate". But after migration, these repositories fail to appear in code search results. I have to manually commit something new to the new repo to trigger report to elastic search, or delete the old elastic search topic and create a new index. I have met this problem on websites, and reported in this issue #16986 , then follow the bugfix of this issue. So I am sure that the code index works well when migrating from UI. But API "/repo/migrate" has a different progress from websites. Here is my guess: In routers\api\v1\repo\migrate.go, gitea use a defer function to notify repo migrate after creating a new empty repo by function repo_module.CreateRepository. Then start a migrate task. The repo is not empty after migration, but in defer function, it still use the original "repo" param, therefore repo.IsEmpty=true, and will not trigger gitea code index to report to elastic search. routers\api\v1\repo\migrate.go ![image](https://user-images.githubusercontent.com/4640297/192973609-a6c3baf8-4d72-4e1c-8d66-dd237c74111b.png) In modules\notification\indexer\indexer.go Gitea only repo to index engine when repo.IsEmpty=false ![image](https://user-images.githubusercontent.com/4640297/192976507-b3e09b39-de39-498e-841f-9ea3aef28601.png) Thanks for reading my question, look forward to your kind reply~~~ ### Gitea Version 1.15.5 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? kubectl ### Database MySQL
Author
Owner

@techknowlogick commented on GitHub (Sep 30, 2022):

1.15.5 is incredibly out of date, please update to latest stable version (which at time of writing is 1.17.2) and try again. I am going to close this issue now, but please re-open if after opening it re-occurs.

@techknowlogick commented on GitHub (Sep 30, 2022): `1.15.5` is incredibly out of date, please update to latest stable version (which at time of writing is 1.17.2) and try again. I am going to close this issue now, but please re-open if after opening it re-occurs.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9634