Skip to content

Commit

Permalink
Not trigger all jobs any more, when re-running the first job (#29439) (
Browse files Browse the repository at this point in the history
…#29441)

Backport #29439 by @sillyguodong

Previously, it will be treated as "re-run all jobs" when `jobIndex ==
0`. So when you click re-run button on the first job, it triggers all
the jobs actually.

Caused by #26535.

Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
  • Loading branch information
GiteaBot and sillyguodong committed Feb 27, 2024
1 parent c758a8a commit 9456deb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions routers/web/repo/actions/view.go
Expand Up @@ -12,6 +12,7 @@ import (
"io"
"net/http"
"net/url"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -260,10 +261,14 @@ func ViewPost(ctx *context_module.Context) {
}

// Rerun will rerun jobs in the given run
// jobIndex = 0 means rerun all jobs
// If jobIndexStr is a blank string, it means rerun all jobs
func Rerun(ctx *context_module.Context) {
runIndex := ctx.ParamsInt64("run")
jobIndex := ctx.ParamsInt64("job")
jobIndexStr := ctx.Params("job")
var jobIndex int64
if jobIndexStr != "" {
jobIndex, _ = strconv.ParseInt(jobIndexStr, 10, 64)
}

run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
if err != nil {
Expand All @@ -284,7 +289,7 @@ func Rerun(ctx *context_module.Context) {
return
}

if jobIndex != 0 {
if jobIndexStr != "" {
jobs = []*actions_model.ActionRunJob{job}
}

Expand Down

0 comments on commit 9456deb

Please sign in to comment.