feat(gitea): default-branch lru cache

Shared LRU avoids repeated Gitea calls for default-branch resolution;
the simple stdlib map alternative would race on concurrent access without
a mutex per entry, which is more code than the LRU.
This commit is contained in:
Mathias Bergqvist
2026-05-04 23:06:06 +02:00
parent fb473262ba
commit 4274b48ea5
7 changed files with 54 additions and 12 deletions

View File

@@ -61,11 +61,11 @@ func (t *WorkflowRunTrigger) Call(ctx context.Context, raw json.RawMessage) (jso
ref := args.Ref
if ref == "" {
repo, err := t.c.GetRepo(ctx, args.Owner, args.Name)
var err error
ref, err = t.c.DefaultBranch(ctx, args.Owner, args.Name)
if err != nil {
return nil, err
}
ref = repo.DefaultBranch
}
result, err := t.c.DispatchWorkflow(ctx, args.Owner, args.Name, args.Workflow, gitea.DispatchWorkflowArgs{