Skip to content

Commit 6df3821

Browse files
committed
fix regexp
1 parent cf52263 commit 6df3821

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

services/actions/commit_status.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"path"
1111
"regexp"
1212
"strconv"
13-
"strings"
1413

1514
actions_model "code.gitea.io/gitea/models/actions"
1615
"code.gitea.io/gitea/models/db"
@@ -86,11 +85,9 @@ func GetRunsFromCommitStatuses(ctx context.Context, statuses []*git_model.Commit
8685
}
8786

8887
func getActionRunAndJobIndexFromCommitStatus(status *git_model.CommitStatus) (int64, int64, error) {
89-
actionsLink, _ := strings.CutPrefix(status.TargetURL, status.Repo.Link()+"/actions/")
90-
// actionsLink should be like "runs/<run_index>/jobs/<job_index>"
91-
92-
re := regexp.MustCompile(`runs/(\d+)/jobs/(\d+)`)
93-
matches := re.FindStringSubmatch(actionsLink)
88+
// status.TargetURL should be like "<repo_link>/actions/runs/<run_index>/jobs/<job_index>"
89+
re := regexp.MustCompile(regexp.QuoteMeta(status.Repo.Link()+"/actions/runs/") + `(\d+)/jobs/(\d+)$`)
90+
matches := re.FindStringSubmatch(status.TargetURL)
9491

9592
if len(matches) != 3 {
9693
return 0, 0, fmt.Errorf("%s is not a Gitea Actions link", status.TargetURL)

0 commit comments

Comments
 (0)