mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
refactor(run): drop the unused job of a run URL
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
2 files changed
+3
-6
No files matched your search
+2
-5
@@ -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:
|
||||
|
||||
@@ -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"`},
|
||||
|
||||
Reference in new issue
Block a user