0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-24 18:33:04 +01:00
Signed-off-by: Bence Santha <git@santha.eu>
This commit is contained in:
Bence Santha 2024-10-02 10:55:31 +02:00
parent a983e12185
commit 8883fadb9a
2 changed files with 9 additions and 7 deletions

View file

@ -623,11 +623,12 @@ func (a ActionWorkflow) ListRepositoryWorkflows(ctx *context.APIContext) {
workflows, err := actions_service.ListActionWorkflows(ctx) workflows, err := actions_service.ListActionWorkflows(ctx)
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "ListActionWorkflows", err)
return return
} }
if len(workflows) == 0 { if len(workflows) == 0 {
ctx.JSON(http.StatusNotFound, nil) ctx.Error(http.StatusNotFound, "ListActionWorkflows", err)
return return
} }
@ -679,11 +680,12 @@ func (a ActionWorkflow) GetWorkflow(ctx *context.APIContext) {
workflow, err := actions_service.GetActionWorkflow(ctx, workflowID) workflow, err := actions_service.GetActionWorkflow(ctx, workflowID)
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "GetActionWorkflow", err)
return return
} }
if workflow == nil { if workflow == nil {
ctx.JSON(http.StatusNotFound, nil) ctx.Error(http.StatusNotFound, "GetActionWorkflow", err)
return return
} }

View file

@ -138,7 +138,7 @@ func GetActionWorkflow(ctx *context.APIContext, workflowID string) (*api.ActionW
} }
} }
return nil, fmt.Errorf("workflow not found") return nil, fmt.Errorf("workflow '%s' not found", workflowID)
} }
func DisableActionWorkflow(ctx *context.APIContext, workflowID string) error { func DisableActionWorkflow(ctx *context.APIContext, workflowID string) error {
@ -150,7 +150,7 @@ func DispatchActionWorkflow(ctx *context.APIContext, workflowID string, opt *api
cfg := cfgUnit.ActionsConfig() cfg := cfgUnit.ActionsConfig()
if cfg.IsWorkflowDisabled(workflowID) { if cfg.IsWorkflowDisabled(workflowID) {
ctx.Error(http.StatusInternalServerError, "WorkflowDisabled", ctx.Tr("actions.workflow.disabled")) ctx.Error(http.StatusInternalServerError, "WorkflowDisabled", fmt.Sprintf("workflow '%s' is disabled", workflowID))
return return
} }
@ -164,12 +164,12 @@ func DispatchActionWorkflow(ctx *context.APIContext, workflowID string, opt *api
case refName.IsBranch(): case refName.IsBranch():
runTargetCommit, err = ctx.Repo.GitRepo.GetBranchCommit(refName.BranchName()) runTargetCommit, err = ctx.Repo.GitRepo.GetBranchCommit(refName.BranchName())
default: default:
ctx.Error(http.StatusInternalServerError, "WorkflowRefNameError", ctx.Tr("form.git_ref_name_error", opt.Ref)) ctx.Error(http.StatusInternalServerError, "WorkflowRefNameError", fmt.Sprintf("%s must be a well-formed Git reference name.", opt.Ref))
return return
} }
if err != nil { if err != nil {
ctx.Error(http.StatusNotFound, "WorkflowRefNotFound", ctx.Tr("form.target_ref_not_exist", opt.Ref)) ctx.Error(http.StatusNotFound, "WorkflowRefNotFound", fmt.Sprintf("target ref does not exist %s", opt.Ref))
return return
} }
@ -204,7 +204,7 @@ func DispatchActionWorkflow(ctx *context.APIContext, workflowID string, opt *api
} }
if workflow == nil { if workflow == nil {
ctx.Error(http.StatusNotFound, "WorkflowNotFound", ctx.Tr("actions.workflow.not_found", workflowID)) ctx.Error(http.StatusNotFound, "WorkflowNotFound", fmt.Sprintf("workflow '%s' is not found", workflowID))
return return
} }