0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-11 17:55:32 +02:00

refactor: use actions_service.CancelRun in web Cancel handler

Replace the duplicated inline cancel logic in the web Cancel handler
with a call to actions_service.CancelRun, which encapsulates the same
transaction, commit status update, and notification logic.

Co-Authored-By: Claude Sonnet (claude-sonnet-4-6) <claude-sonnet-4-6@anthropic.com>
This commit is contained in:
Ross Golder 2026-05-04 06:44:06 +07:00
parent 678e17367b
commit ee37427d38
No known key found for this signature in database
GPG Key ID: 253A7E508D2D59CD

View File

@ -756,27 +756,10 @@ func Cancel(ctx *context_module.Context) {
return
}
var updatedJobs []*actions_model.ActionRunJob
if err := db.WithTx(ctx, func(ctx context.Context) error {
cancelledJobs, err := actions_model.CancelJobs(ctx, jobs)
if err != nil {
return fmt.Errorf("cancel jobs: %w", err)
}
updatedJobs = append(updatedJobs, cancelledJobs...)
return nil
}); err != nil {
ctx.ServerError("StopTask", err)
if err := actions_service.CancelRun(ctx, run, jobs); err != nil {
ctx.ServerError("CancelRun", err)
return
}
actions_service.CreateCommitStatusForRunJobs(ctx, run, jobs...)
actions_service.EmitJobsIfReadyByJobs(updatedJobs)
actions_service.NotifyWorkflowJobsStatusUpdate(ctx, updatedJobs...)
if len(updatedJobs) > 0 {
actions_service.NotifyWorkflowRunStatusUpdateWithReload(ctx, run.RepoID, run.ID)
}
ctx.JSONOK()
}