Allow to sync tags from admin dashboard (#28045)

Inspired by #28043

This PR adds a option to the Admin Dashboard to sync all tags to the
database.


![grafik](26ac51ef-82a4-4fd9-a6a6-5aefec612ff6)
This commit is contained in:
JakobDev 2024-01-24 04:02:04 +01:00 committed by GitHub
parent f3ba3e922d
commit 4567a3a1ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 100 additions and 0 deletions

View file

@ -45,6 +45,7 @@ import (
repo_migrations "code.gitea.io/gitea/services/migrations"
mirror_service "code.gitea.io/gitea/services/mirror"
pull_service "code.gitea.io/gitea/services/pull"
release_service "code.gitea.io/gitea/services/release"
repo_service "code.gitea.io/gitea/services/repository"
"code.gitea.io/gitea/services/repository/archiver"
"code.gitea.io/gitea/services/task"
@ -138,6 +139,8 @@ func InitWebInstalled(ctx context.Context) {
mustInit(system.Init)
mustInitCtx(ctx, oauth2.Init)
mustInit(release_service.Init)
mustInitCtx(ctx, models.Init)
mustInitCtx(ctx, authmodel.Init)
mustInitCtx(ctx, repo_service.Init)

View file

@ -23,6 +23,7 @@ import (
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/services/cron"
"code.gitea.io/gitea/services/forms"
release_service "code.gitea.io/gitea/services/release"
repo_service "code.gitea.io/gitea/services/repository"
)
@ -157,6 +158,13 @@ func DashboardPost(ctx *context.Context) {
}
}()
ctx.Flash.Success(ctx.Tr("admin.dashboard.sync_branch.started"))
case "sync_repo_tags":
go func() {
if err := release_service.AddAllRepoTagsToSyncQueue(graceful.GetManager().ShutdownContext()); err != nil {
log.Error("AddAllRepoTagsToSyncQueue: %v: %v", ctx.Doer.ID, err)
}
}()
ctx.Flash.Success(ctx.Tr("admin.dashboard.sync_tag.started"))
default:
task := cron.GetTask(form.Op)
if task != nil {