diff options
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/repo/action.go | 30 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 12 |
2 files changed, 32 insertions, 10 deletions
diff --git a/routers/api/v1/repo/action.go b/routers/api/v1/repo/action.go index 99eef2f53b..25aabe6dd2 100644 --- a/routers/api/v1/repo/action.go +++ b/routers/api/v1/repo/action.go @@ -1132,18 +1132,23 @@ func GetWorkflowRun(ctx *context.APIContext) { // "$ref": "#/responses/notFound" runID := ctx.PathParamInt64("run") - job, _, err := db.GetByID[actions_model.ActionRun](ctx, runID) + job, has, err := db.GetByID[actions_model.ActionRun](ctx, runID) + if err != nil { + ctx.APIErrorInternal(err) + return + } - if err != nil || job.RepoID != ctx.Repo.Repository.ID { - ctx.APIError(http.StatusNotFound, util.ErrNotExist) + if !has || job.RepoID != ctx.Repo.Repository.ID { + ctx.APIErrorNotFound(util.ErrNotExist) + return } - convertedArtifact, err := convert.ToActionWorkflowRun(ctx, ctx.Repo.Repository, job) + convertedRun, err := convert.ToActionWorkflowRun(ctx, ctx.Repo.Repository, job) if err != nil { ctx.APIErrorInternal(err) return } - ctx.JSON(http.StatusOK, convertedArtifact) + ctx.JSON(http.StatusOK, convertedRun) } // ListWorkflowRunJobs Lists all jobs for a workflow run. @@ -1237,10 +1242,15 @@ func GetWorkflowJob(ctx *context.APIContext) { // "$ref": "#/responses/notFound" jobID := ctx.PathParamInt64("job_id") - job, _, err := db.GetByID[actions_model.ActionRunJob](ctx, jobID) + job, has, err := db.GetByID[actions_model.ActionRunJob](ctx, jobID) + if err != nil { + ctx.APIErrorInternal(err) + return + } - if err != nil || job.RepoID != ctx.Repo.Repository.ID { - ctx.APIError(http.StatusNotFound, util.ErrNotExist) + if !has || job.RepoID != ctx.Repo.Repository.ID { + ctx.APIErrorNotFound(util.ErrNotExist) + return } convertedWorkflowJob, err := convert.ToActionWorkflowJob(ctx, ctx.Repo.Repository, nil, job) @@ -1251,7 +1261,7 @@ func GetWorkflowJob(ctx *context.APIContext) { ctx.JSON(http.StatusOK, convertedWorkflowJob) } -// GetArtifacts Lists all artifacts for a repository. +// GetArtifactsOfRun Lists all artifacts for a repository. func GetArtifactsOfRun(ctx *context.APIContext) { // swagger:operation GET /repos/{owner}/{repo}/actions/runs/{run}/artifacts repository getArtifactsOfRun // --- @@ -1354,7 +1364,7 @@ func DeleteActionRun(ctx *context.APIContext) { runID := ctx.PathParamInt64("run") run, err := actions_model.GetRunByRepoAndID(ctx, ctx.Repo.Repository.ID, runID) if errors.Is(err, util.ErrNotExist) { - ctx.APIError(http.StatusNotFound, err) + ctx.APIErrorNotFound(err) return } else if err != nil { ctx.APIErrorInternal(err) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 7b3858ccb1..e69b7729a0 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -869,6 +869,18 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error { } } + if opts.HasCode != nil && !unit_model.TypeCode.UnitGlobalDisabled() { + if *opts.HasCode { + units = append(units, repo_model.RepoUnit{ + RepoID: repo.ID, + Type: unit_model.TypeCode, + Config: &repo_model.UnitConfig{}, + }) + } else { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeCode) + } + } + if opts.HasPullRequests != nil && !unit_model.TypePullRequests.UnitGlobalDisabled() { if *opts.HasPullRequests { // We do allow setting individual PR settings through the API, so |