Browse Source

Return err in ToActionTask

pull/26673/head
chesterip 1 week ago
parent
commit
2d53041157
2 changed files with 9 additions and 4 deletions
  1. 6
    1
      routers/api/v1/repo/actions.go
  2. 3
    3
      services/convert/convert.go

+ 6
- 1
routers/api/v1/repo/actions.go View File

@@ -68,7 +68,12 @@ func ListActionTasks(ctx *context.APIContext) {

res.Entries = make([]*api.ActionTask, len(tasks))
for i := range tasks {
res.Entries[i] = convert.ToActionTask(ctx, ctx.Repo.Repository, tasks[i])
convertedTask, err := convert.ToActionTask(ctx, ctx.Repo.Repository, tasks[i])
if err != nil {
ctx.Error(http.StatusInternalServerError, "ToActionTask", err)
return
}
res.Entries[i] = convertedTask
}

ctx.JSON(http.StatusOK, &res)

+ 3
- 3
services/convert/convert.go View File

@@ -196,9 +196,9 @@ func ToTag(repo *repo_model.Repository, t *git.Tag) *api.Tag {
}

// ToActionTask convert a actions_model.ActionTask to an api.ActionTask
func ToActionTask(ctx context.Context, repo *repo_model.Repository, t *actions_model.ActionTask) *api.ActionTask {
func ToActionTask(ctx context.Context, repo *repo_model.Repository, t *actions_model.ActionTask) (*api.ActionTask, error) {
if err := t.LoadAttributes(ctx); err != nil {
panic(fmt.Sprintf("failed to execute ActionTask.LoadAttributes(): %v", err))
return nil, err
}

url := strings.TrimSuffix(setting.AppURL, "/") + t.GetRunLink()
@@ -217,7 +217,7 @@ func ToActionTask(ctx context.Context, repo *repo_model.Repository, t *actions_m
CreatedAt: t.Created.AsLocalTime(),
UpdatedAt: t.Updated.AsLocalTime(),
RunStartedAt: t.Started.AsLocalTime(),
}
}, nil
}

// ToVerification convert a git.Commit.Signature to an api.PayloadCommitVerification

Loading…
Cancel
Save