diff --git a/internal/app/ref.go b/internal/app/ref.go index 201a6bfc..20a8051f 100644 --- a/internal/app/ref.go +++ b/internal/app/ref.go @@ -35,8 +35,6 @@ const ( // ref is a parsed reference argument. type ref struct { Number int64 - // Job is the job of a run URL ending in /jobs/M, else 0. - Job int64 // Repo is the repository the reference names, as a repository argument (a URL, // [HOST/]OWNER/REPO or NAME); it is empty for N and #N. Repo string @@ -92,10 +90,9 @@ func parseRefURL(raw string, kind refKind) (ref, error) { result := ref{} switch { case kind == runRef && at(i) == "actions" && at(i+1) == "runs" && positive(i+2) > 0: + // Since Gitea 1.26 the web URL holds the run ID, which the API takes too; a trailing + // /jobs/M only selects a job on the web page. result.Number = positive(i + 2) - if at(i+3) == "jobs" { - result.Job = positive(i + 4) - } case kind != runRef && (at(i) == "issues" || at(i) == "pulls") && positive(i+1) > 0: result.Number = positive(i + 1) default: diff --git a/internal/app/ref_test.go b/internal/app/ref_test.go index f74c5054..814569e5 100644 --- a/internal/app/ref_test.go +++ b/internal/app/ref_test.go @@ -33,7 +33,7 @@ func TestParseRefAcceptsNumbersQualifiedNumbersAndURLs(t *testing.T) { {raw: "https://gitea.com/alice/issues/issues/4", want: ref{Number: 4, Repo: "https://gitea.com/alice/issues"}}, {raw: "https://gitea.com/alice/project/pulls/7", kind: issueRef, want: ref{Number: 7, Repo: "https://gitea.com/alice/project"}}, {raw: "https://gitea.com/alice/project/actions/runs/34", kind: runRef, want: ref{Number: 34, Repo: "https://gitea.com/alice/project"}}, - {raw: "https://gitea.com/alice/project/actions/runs/34/jobs/2", kind: runRef, want: ref{Number: 34, Job: 2, Repo: "https://gitea.com/alice/project"}}, + {raw: "https://gitea.com/alice/project/actions/runs/34/jobs/2", kind: runRef, want: ref{Number: 34, Repo: "https://gitea.com/alice/project"}}, {raw: "#34", kind: runRef, want: ref{Number: 34}}, {raw: "0", err: `invalid issue "0": use a number, #number, OWNER/REPO#number or URL`}, {raw: "#abc", kind: pullRef, err: `invalid pull request "#abc"`},