mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-21 09:06:46 +09:00
refactor(actions): small cleanups across models, services and routers (#39722)
Collection of small, behaviour-preserving cleanups in the Actions code. - Fix log and error prefixes that named non-existent or wrong functions, and wrap errors with `%w` so `errors.Is` keeps working. - Remove unused code. - Rely on `ctx.ServerError` / `ctx.APIErrorAuto`, which already map `util.ErrNotExist` and friends, instead of equivalent hand-written switches. - Load runs referenced by commit statuses with one query instead of one per run (used on every PR view); the result order is now stable. - Encode an event's payload once instead of up to three times. - Share the duplicated runner-token "get or create" logic and the "notify and emit" call pair. - Simplify `ToActionArtifact` / `ToActionRunner` signatures. --------- Signed-off-by: bircni <bircni@icloud.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
26 files changed
+113
-223
No files matched your search
@@ -139,16 +139,9 @@ func Runners(ctx *context.Context) {
|
||||
}
|
||||
|
||||
// ownid=0,repo_id=0,means this token is used for global
|
||||
var token *actions_model.ActionRunnerToken
|
||||
token, err = actions_model.GetLatestRunnerToken(ctx, opts.OwnerID, opts.RepoID)
|
||||
if errors.Is(err, util.ErrNotExist) || (token != nil && !token.IsActive) {
|
||||
token, err = actions_model.NewRunnerToken(ctx, opts.OwnerID, opts.RepoID)
|
||||
if err != nil {
|
||||
ctx.ServerError("CreateRunnerToken", err)
|
||||
return
|
||||
}
|
||||
} else if err != nil {
|
||||
ctx.ServerError("GetLatestRunnerToken", err)
|
||||
token, err := actions_model.GetOrCreateActiveRunnerToken(ctx, opts.OwnerID, opts.RepoID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOrCreateActiveRunnerToken", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user