snapshot of https://github.com/go-gitea/gitea.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
This commit is contained in:
61
services/release/tag.go
Normal file
61
services/release/tag.go
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package release
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"gitea.dev/models/db"
|
||||
repo_model "gitea.dev/models/repo"
|
||||
"gitea.dev/modules/graceful"
|
||||
"gitea.dev/modules/log"
|
||||
"gitea.dev/modules/queue"
|
||||
repo_module "gitea.dev/modules/repository"
|
||||
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
type TagSyncOptions struct {
|
||||
RepoID int64
|
||||
}
|
||||
|
||||
// tagSyncQueue represents a queue to handle tag sync jobs.
|
||||
var tagSyncQueue *queue.WorkerPoolQueue[*TagSyncOptions]
|
||||
|
||||
func handlerTagSync(items ...*TagSyncOptions) []*TagSyncOptions {
|
||||
for _, opts := range items {
|
||||
err := repo_module.SyncRepoTags(graceful.GetManager().ShutdownContext(), opts.RepoID)
|
||||
if err != nil {
|
||||
log.Error("syncRepoTags [%d] failed: %v", opts.RepoID, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func addRepoToTagSyncQueue(repoID int64) error {
|
||||
return tagSyncQueue.Push(&TagSyncOptions{
|
||||
RepoID: repoID,
|
||||
})
|
||||
}
|
||||
|
||||
func initTagSyncQueue(ctx context.Context) error {
|
||||
tagSyncQueue = queue.CreateUniqueQueue(ctx, "tag_sync", handlerTagSync)
|
||||
if tagSyncQueue == nil {
|
||||
return errors.New("unable to create tag_sync queue")
|
||||
}
|
||||
go graceful.GetManager().RunWithCancel(tagSyncQueue)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func AddAllRepoTagsToSyncQueue(ctx context.Context) error {
|
||||
if err := db.Iterate(ctx, builder.Eq{"is_empty": false}, func(ctx context.Context, repo *repo_model.Repository) error {
|
||||
return addRepoToTagSyncQueue(repo.ID)
|
||||
}); err != nil {
|
||||
return fmt.Errorf("run sync all tags failed: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user