From 4b7d307d34a307cbf03a4234b7bd83cc391ded7e Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 12 Nov 2023 10:48:18 +0100 Subject: [PATCH 1/9] fix env vars --- docs/docs/20-usage/50-environment.md | 6 +++++- pipeline/frontend/metadata.go | 1 + pipeline/frontend/metadata/environment.go | 16 ++++++++++++++-- pipeline/frontend/metadata/types.go | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index 3dd5d801d1..aee081f472 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -80,7 +80,8 @@ This is the reference list of all environment variables available to your pipeli | `CI_PIPELINE_NUMBER` | pipeline number | | `CI_PIPELINE_PARENT` | number of parent pipeline | | `CI_PIPELINE_EVENT` | pipeline event (push, pull_request, tag, deployment) | -| `CI_PIPELINE_URL` | link to the forge's web UI for the commit(s) or tag that triggered the pipeline | +| `CI_PIPELINE_URL` | link to the web UI for the pipeline | +| `CI_PIPELINE_FORGE_URL` | link to the forge's web UI for the commit(s) or tag that triggered the pipeline | | `CI_PIPELINE_DEPLOY_TARGET` | pipeline deploy target for `deployment` events (ie production) | | `CI_PIPELINE_STATUS` | pipeline status (success, failure) | | `CI_PIPELINE_CREATED` | pipeline created UNIX timestamp | @@ -90,9 +91,11 @@ This is the reference list of all environment variables available to your pipeli | `CI_WORKFLOW_NAME` | workflow name | | | **Current step** | | `CI_STEP_NAME` | step name | +| `CI_STEP_NUMBER` | step number | | `CI_STEP_STATUS` | step status (success, failure) | | `CI_STEP_STARTED` | step started UNIX timestamp | | `CI_STEP_FINISHED` | step finished UNIX timestamp | +| `CI_STEP_URL` | URL to step in UI | | | **Previous commit** | | `CI_PREV_COMMIT_SHA` | previous commit SHA | | `CI_PREV_COMMIT_REF` | previous commit ref | @@ -110,6 +113,7 @@ This is the reference list of all environment variables available to your pipeli | `CI_PREV_PIPELINE_PARENT` | previous pipeline number of parent pipeline | | `CI_PREV_PIPELINE_EVENT` | previous pipeline event (push, pull_request, tag, deployment) | | `CI_PREV_PIPELINE_URL` | previous pipeline link in CI | +| `CI_PREV_PIPELINE_FORGE_URL` | previous pipeline link to event in forge | | `CI_PREV_PIPELINE_DEPLOY_TARGET` | previous pipeline deploy target for `deployment` events (ie production) | | `CI_PREV_PIPELINE_STATUS` | previous pipeline status (success, failure) | | `CI_PREV_PIPELINE_CREATED` | previous pipeline created UNIX timestamp | diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index 2a669c9051..f748c00be0 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -55,6 +55,7 @@ func MetadataFromStruct(forge metadata.ServerForge, repo *model.Repo, pipeline, fRepo := metadata.Repo{} if repo != nil { fRepo = metadata.Repo{ + ID: repo.ID, Name: repo.Name, Owner: repo.Owner, RemoteID: fmt.Sprint(repo.ForgeRemoteID), diff --git a/pipeline/frontend/metadata/environment.go b/pipeline/frontend/metadata/environment.go index 6055dcab96..ddfc344ba7 100644 --- a/pipeline/frontend/metadata/environment.go +++ b/pipeline/frontend/metadata/environment.go @@ -15,6 +15,7 @@ package metadata import ( + "fmt" "path" "regexp" "strconv" @@ -68,7 +69,8 @@ func (m *Metadata) Environ() map[string]string { "CI_PIPELINE_NUMBER": strconv.FormatInt(m.Curr.Number, 10), "CI_PIPELINE_PARENT": strconv.FormatInt(m.Curr.Parent, 10), "CI_PIPELINE_EVENT": m.Curr.Event, - "CI_PIPELINE_URL": m.Curr.Link, + "CI_PIPELINE_URL": m.getPipelineStatusLink(m.Curr, 0), + "CI_PIPELINE_FORGE_URL": m.Curr.Link, "CI_PIPELINE_DEPLOY_TARGET": m.Curr.Target, "CI_PIPELINE_STATUS": m.Curr.Status, "CI_PIPELINE_CREATED": strconv.FormatInt(m.Curr.Created, 10), @@ -83,6 +85,7 @@ func (m *Metadata) Environ() map[string]string { "CI_STEP_STATUS": "", // will be set by agent "CI_STEP_STARTED": "", // will be set by agent "CI_STEP_FINISHED": "", // will be set by agent + "CI_STEP_URL": m.getPipelineStatusLink(m.Curr, m.Step.Number), "CI_PREV_COMMIT_SHA": m.Prev.Commit.Sha, "CI_PREV_COMMIT_REF": m.Prev.Commit.Ref, @@ -97,7 +100,8 @@ func (m *Metadata) Environ() map[string]string { "CI_PREV_PIPELINE_NUMBER": strconv.FormatInt(m.Prev.Number, 10), "CI_PREV_PIPELINE_PARENT": strconv.FormatInt(m.Prev.Parent, 10), "CI_PREV_PIPELINE_EVENT": m.Prev.Event, - "CI_PREV_PIPELINE_URL": m.Prev.Link, + "CI_PREV_PIPELINE_URL": m.getPipelineStatusLink(m.Prev, 0), + "CI_PREV_PIPELINE_FORGE_URL": m.Curr.Link, "CI_PREV_PIPELINE_DEPLOY_TARGET": m.Prev.Target, "CI_PREV_PIPELINE_STATUS": m.Prev.Status, "CI_PREV_PIPELINE_CREATED": strconv.FormatInt(m.Prev.Created, 10), @@ -123,3 +127,11 @@ func (m *Metadata) Environ() map[string]string { return params } + +func (m *Metadata) getPipelineStatusLink(pipeline Pipeline, stepNumber int) string { + if stepNumber == 0 { + return fmt.Sprintf("%s/repos/%d/pipeline/%d", m.Sys.Link, m.Repo.ID, pipeline.Number) + } + + return fmt.Sprintf("%s/repos/%d/pipeline/%d/%d", m.Sys.Link, m.Repo.ID, pipeline.Number, stepNumber) +} diff --git a/pipeline/frontend/metadata/types.go b/pipeline/frontend/metadata/types.go index ef17d57b21..48e0ed873d 100644 --- a/pipeline/frontend/metadata/types.go +++ b/pipeline/frontend/metadata/types.go @@ -29,6 +29,7 @@ type ( // Repo defines runtime metadata for a repository. Repo struct { + ID int64 `json:"id,omitempty"` Name string `json:"name,omitempty"` Owner string `json:"owner,omitempty"` RemoteID string `json:"remote_id,omitempty"` From 3fa8605d9d879435c0fcf0c6fea75c9847a33599 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 12 Nov 2023 11:09:50 +0100 Subject: [PATCH 2/9] start rename --- cli/exec/flags.go | 8 ++--- cli/exec/metadata.go | 8 ++--- cmd/server/docs/docs.go | 12 +++---- pipeline/frontend/metadata.go | 12 +++---- pipeline/frontend/metadata/environment.go | 24 +++++++------- pipeline/frontend/metadata/types.go | 6 ++-- pipeline/frontend/metadata_test.go | 6 ++-- .../frontend/yaml/compiler/compiler_test.go | 2 +- pipeline/frontend/yaml/compiler/option.go | 4 +-- .../frontend/yaml/compiler/option_test.go | 4 +-- pipeline/rpc/proto/woodpecker.pb.go | 2 +- pipeline/stepBuilder.go | 2 +- server/api/pipeline.go | 2 +- server/ccmenu/cc.go | 4 +-- server/cron/cron.go | 2 +- server/forge/bitbucket/convert.go | 6 ++-- server/forge/bitbucket/convert_test.go | 6 ++-- server/forge/gitea/gitea_test.go | 2 +- server/forge/gitea/helper.go | 8 ++--- server/forge/gitea/helper_test.go | 12 +++---- server/forge/github/convert.go | 4 +-- server/forge/github/convert_test.go | 8 ++--- server/forge/github/github.go | 2 +- server/forge/github/github_test.go | 4 +-- server/forge/github/parse.go | 6 ++-- server/forge/gitlab/convert.go | 10 +++--- server/forge/mocks/forge.go | 2 +- server/model/pipeline.go | 2 +- server/model/repo.go | 4 +-- .../datastore/migration/027_link_to_url.go | 31 +++++++++++++++++++ server/store/mocks/store.go | 2 +- web/src/lib/api/types/pipeline.ts | 5 ++- web/src/lib/api/types/repo.ts | 4 +-- woodpecker-go/woodpecker/types.go | 4 +-- 34 files changed, 125 insertions(+), 95 deletions(-) create mode 100644 server/store/datastore/migration/027_link_to_url.go diff --git a/cli/exec/flags.go b/cli/exec/flags.go index 78de9714a4..23caa54e59 100644 --- a/cli/exec/flags.go +++ b/cli/exec/flags.go @@ -130,7 +130,7 @@ var flags = []cli.Flag{ }, &cli.StringFlag{ EnvVars: []string{"CI_SYSTEM_URL"}, - Name: "system-link", + Name: "system-url", Value: "https://github.com/woodpecker-ci/woodpecker", }, &cli.StringFlag{ @@ -144,7 +144,7 @@ var flags = []cli.Flag{ }, &cli.StringFlag{ EnvVars: []string{"CI_REPO_URL"}, - Name: "repo-link", + Name: "repo-url", }, &cli.StringFlag{ EnvVars: []string{"CI_REPO_CLONE_URL"}, @@ -193,7 +193,7 @@ var flags = []cli.Flag{ }, &cli.StringFlag{ EnvVars: []string{"CI_PIPELINE_URL"}, - Name: "pipeline-link", + Name: "pipeline-url", }, &cli.StringFlag{ EnvVars: []string{"CI_PIPELINE_TARGET"}, @@ -257,7 +257,7 @@ var flags = []cli.Flag{ }, &cli.StringFlag{ EnvVars: []string{"CI_PREV_PIPELINE_URL"}, - Name: "prev-pipeline-link", + Name: "prev-pipeline-url", }, &cli.StringFlag{ EnvVars: []string{"CI_PREV_COMMIT_SHA"}, diff --git a/cli/exec/metadata.go b/cli/exec/metadata.go index 2336ede513..8adf5244c0 100644 --- a/cli/exec/metadata.go +++ b/cli/exec/metadata.go @@ -45,7 +45,7 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata { Name: repoName, Owner: repoOwner, RemoteID: c.String("repo-remote-id"), - Link: c.String("repo-link"), + URL: c.String("repo-url"), CloneURL: c.String("repo-clone-url"), CloneSSHURL: c.String("repo-clone-ssh-url"), Private: c.Bool("repo-private"), @@ -59,7 +59,7 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata { Finished: c.Int64("pipeline-finished"), Status: c.String("pipeline-status"), Event: c.String("pipeline-event"), - Link: c.String("pipeline-link"), + URL: c.String("pipeline-url"), Target: c.String("pipeline-target"), Commit: metadata.Commit{ Sha: c.String("commit-sha"), @@ -81,7 +81,7 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata { Finished: c.Int64("prev-pipeline-finished"), Status: c.String("prev-pipeline-status"), Event: c.String("prev-pipeline-event"), - Link: c.String("prev-pipeline-link"), + URL: c.String("prev-pipeline-url"), Commit: metadata.Commit{ Sha: c.String("prev-commit-sha"), Ref: c.String("prev-commit-ref"), @@ -106,7 +106,7 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata { }, Sys: metadata.System{ Name: c.String("system-name"), - Link: c.String("system-link"), + URL: c.String("system-url"), Platform: platform, Version: version.Version, }, diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index efe3474730..1a628cb2aa 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -3966,9 +3966,6 @@ const docTemplate = `{ "id": { "type": "integer" }, - "link_url": { - "type": "string" - }, "message": { "type": "string" }, @@ -4015,6 +4012,9 @@ const docTemplate = `{ "updated_at": { "type": "integer" }, + "url": { + "type": "string" + }, "variables": { "type": "object", "additionalProperties": { @@ -4120,9 +4120,6 @@ const docTemplate = `{ "id": { "type": "integer" }, - "link_url": { - "type": "string" - }, "name": { "type": "string" }, @@ -4147,6 +4144,9 @@ const docTemplate = `{ "trusted": { "type": "boolean" }, + "url": { + "type": "string" + }, "visibility": { "$ref": "#/definitions/RepoVisibility" } diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index f748c00be0..4bc7efb179 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -37,9 +37,9 @@ func EnvVarSubst(yaml string, environ map[string]string) (string, error) { } // MetadataFromStruct return the metadata from a pipeline will run with. -func MetadataFromStruct(forge metadata.ServerForge, repo *model.Repo, pipeline, last *model.Pipeline, workflow *model.Workflow, link string) metadata.Metadata { - host := link - uri, err := url.Parse(link) +func MetadataFromStruct(forge metadata.ServerForge, repo *model.Repo, pipeline, last *model.Pipeline, workflow *model.Workflow, sysURL string) metadata.Metadata { + host := sysURL + uri, err := url.Parse(sysURL) if err == nil { host = uri.Host } @@ -59,7 +59,7 @@ func MetadataFromStruct(forge metadata.ServerForge, repo *model.Repo, pipeline, Name: repo.Name, Owner: repo.Owner, RemoteID: fmt.Sprint(repo.ForgeRemoteID), - Link: repo.Link, + URL: repo.URL, CloneURL: repo.Clone, CloneSSHURL: repo.CloneSSH, Private: repo.IsSCMPrivate, @@ -94,7 +94,7 @@ func MetadataFromStruct(forge metadata.ServerForge, repo *model.Repo, pipeline, Step: metadata.Step{}, Sys: metadata.System{ Name: "woodpecker", - Link: link, + URL: sysURL, Host: host, Platform: "", // will be set by pipeline platform option or by agent Version: version.Version, @@ -126,7 +126,7 @@ func metadataPipelineFromModelPipeline(pipeline *model.Pipeline, includeParent b Finished: pipeline.Finished, Status: string(pipeline.Status), Event: string(pipeline.Event), - Link: pipeline.Link, + URL: pipeline.URL, Target: pipeline.Deploy, Commit: metadata.Commit{ Sha: pipeline.Commit, diff --git a/pipeline/frontend/metadata/environment.go b/pipeline/frontend/metadata/environment.go index ddfc344ba7..0d00a8cdcf 100644 --- a/pipeline/frontend/metadata/environment.go +++ b/pipeline/frontend/metadata/environment.go @@ -44,7 +44,7 @@ func (m *Metadata) Environ() map[string]string { "CI_REPO_OWNER": m.Repo.Owner, "CI_REPO_REMOTE_ID": m.Repo.RemoteID, "CI_REPO_SCM": "git", - "CI_REPO_URL": m.Repo.Link, + "CI_REPO_URL": m.Repo.URL, "CI_REPO_CLONE_URL": m.Repo.CloneURL, "CI_REPO_CLONE_SSH_URL": m.Repo.CloneSSHURL, "CI_REPO_DEFAULT_BRANCH": m.Repo.Branch, @@ -57,7 +57,7 @@ func (m *Metadata) Environ() map[string]string { "CI_COMMIT_BRANCH": m.Curr.Commit.Branch, "CI_COMMIT_SOURCE_BRANCH": sourceBranch, "CI_COMMIT_TARGET_BRANCH": targetBranch, - "CI_COMMIT_URL": m.Curr.Link, + "CI_COMMIT_URL": m.Curr.URL, "CI_COMMIT_MESSAGE": m.Curr.Commit.Message, "CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, "CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, @@ -69,8 +69,8 @@ func (m *Metadata) Environ() map[string]string { "CI_PIPELINE_NUMBER": strconv.FormatInt(m.Curr.Number, 10), "CI_PIPELINE_PARENT": strconv.FormatInt(m.Curr.Parent, 10), "CI_PIPELINE_EVENT": m.Curr.Event, - "CI_PIPELINE_URL": m.getPipelineStatusLink(m.Curr, 0), - "CI_PIPELINE_FORGE_URL": m.Curr.Link, + "CI_PIPELINE_URL": m.getPipelineStatusURL(m.Curr, 0), + "CI_PIPELINE_FORGE_URL": m.Curr.URL, "CI_PIPELINE_DEPLOY_TARGET": m.Curr.Target, "CI_PIPELINE_STATUS": m.Curr.Status, "CI_PIPELINE_CREATED": strconv.FormatInt(m.Curr.Created, 10), @@ -85,13 +85,13 @@ func (m *Metadata) Environ() map[string]string { "CI_STEP_STATUS": "", // will be set by agent "CI_STEP_STARTED": "", // will be set by agent "CI_STEP_FINISHED": "", // will be set by agent - "CI_STEP_URL": m.getPipelineStatusLink(m.Curr, m.Step.Number), + "CI_STEP_URL": m.getPipelineStatusURL(m.Curr, m.Step.Number), "CI_PREV_COMMIT_SHA": m.Prev.Commit.Sha, "CI_PREV_COMMIT_REF": m.Prev.Commit.Ref, "CI_PREV_COMMIT_REFSPEC": m.Prev.Commit.Refspec, "CI_PREV_COMMIT_BRANCH": m.Prev.Commit.Branch, - "CI_PREV_COMMIT_URL": m.Prev.Link, + "CI_PREV_COMMIT_URL": m.Prev.URL, "CI_PREV_COMMIT_MESSAGE": m.Prev.Commit.Message, "CI_PREV_COMMIT_AUTHOR": m.Prev.Commit.Author.Name, "CI_PREV_COMMIT_AUTHOR_EMAIL": m.Prev.Commit.Author.Email, @@ -100,8 +100,8 @@ func (m *Metadata) Environ() map[string]string { "CI_PREV_PIPELINE_NUMBER": strconv.FormatInt(m.Prev.Number, 10), "CI_PREV_PIPELINE_PARENT": strconv.FormatInt(m.Prev.Parent, 10), "CI_PREV_PIPELINE_EVENT": m.Prev.Event, - "CI_PREV_PIPELINE_URL": m.getPipelineStatusLink(m.Prev, 0), - "CI_PREV_PIPELINE_FORGE_URL": m.Curr.Link, + "CI_PREV_PIPELINE_URL": m.getPipelineStatusURL(m.Prev, 0), + "CI_PREV_PIPELINE_FORGE_URL": m.Curr.URL, "CI_PREV_PIPELINE_DEPLOY_TARGET": m.Prev.Target, "CI_PREV_PIPELINE_STATUS": m.Prev.Status, "CI_PREV_PIPELINE_CREATED": strconv.FormatInt(m.Prev.Created, 10), @@ -109,7 +109,7 @@ func (m *Metadata) Environ() map[string]string { "CI_PREV_PIPELINE_FINISHED": strconv.FormatInt(m.Prev.Finished, 10), "CI_SYSTEM_NAME": m.Sys.Name, - "CI_SYSTEM_URL": m.Sys.Link, + "CI_SYSTEM_URL": m.Sys.URL, "CI_SYSTEM_HOST": m.Sys.Host, "CI_SYSTEM_PLATFORM": m.Sys.Platform, // will be set by pipeline platform option or by agent "CI_SYSTEM_VERSION": m.Sys.Version, @@ -128,10 +128,10 @@ func (m *Metadata) Environ() map[string]string { return params } -func (m *Metadata) getPipelineStatusLink(pipeline Pipeline, stepNumber int) string { +func (m *Metadata) getPipelineStatusURL(pipeline Pipeline, stepNumber int) string { if stepNumber == 0 { - return fmt.Sprintf("%s/repos/%d/pipeline/%d", m.Sys.Link, m.Repo.ID, pipeline.Number) + return fmt.Sprintf("%s/repos/%d/pipeline/%d", m.Sys.URL, m.Repo.ID, pipeline.Number) } - return fmt.Sprintf("%s/repos/%d/pipeline/%d/%d", m.Sys.Link, m.Repo.ID, pipeline.Number, stepNumber) + return fmt.Sprintf("%s/repos/%d/pipeline/%d/%d", m.Sys.URL, m.Repo.ID, pipeline.Number, stepNumber) } diff --git a/pipeline/frontend/metadata/types.go b/pipeline/frontend/metadata/types.go index 48e0ed873d..7f46e52c62 100644 --- a/pipeline/frontend/metadata/types.go +++ b/pipeline/frontend/metadata/types.go @@ -33,7 +33,7 @@ type ( Name string `json:"name,omitempty"` Owner string `json:"owner,omitempty"` RemoteID string `json:"remote_id,omitempty"` - Link string `json:"link,omitempty"` + URL string `json:"link,omitempty"` CloneURL string `json:"clone_url,omitempty"` CloneSSHURL string `json:"clone_url_ssh,omitempty"` Private bool `json:"private,omitempty"` @@ -51,7 +51,7 @@ type ( Timeout int64 `json:"timeout,omitempty"` Status string `json:"status,omitempty"` Event string `json:"event,omitempty"` - Link string `json:"link,omitempty"` + URL string `json:"link,omitempty"` Target string `json:"target,omitempty"` Trusted bool `json:"trusted,omitempty"` Commit Commit `json:"commit,omitempty"` @@ -103,7 +103,7 @@ type ( System struct { Name string `json:"name,omitempty"` Host string `json:"host,omitempty"` - Link string `json:"link,omitempty"` + URL string `json:"link,omitempty"` Platform string `json:"arch,omitempty"` Version string `json:"version,omitempty"` } diff --git a/pipeline/frontend/metadata_test.go b/pipeline/frontend/metadata_test.go index dbbbe67a78..0d73d10e56 100644 --- a/pipeline/frontend/metadata_test.go +++ b/pipeline/frontend/metadata_test.go @@ -88,15 +88,15 @@ func TestMetadataFromStruct(t *testing.T) { { name: "Test with forge", forge: forge, - repo: &model.Repo{FullName: "testUser/testRepo", Link: "https://gitea.com/testUser/testRepo", Clone: "https://gitea.com/testUser/testRepo.git", CloneSSH: "git@gitea.com:testUser/testRepo.git", Branch: "main", IsSCMPrivate: true}, + repo: &model.Repo{FullName: "testUser/testRepo", URL: "https://gitea.com/testUser/testRepo", Clone: "https://gitea.com/testUser/testRepo.git", CloneSSH: "git@gitea.com:testUser/testRepo.git", Branch: "main", IsSCMPrivate: true}, pipeline: &model.Pipeline{Number: 3}, last: &model.Pipeline{Number: 2}, workflow: &model.Workflow{Name: "hello"}, link: "https://example.com", expectedMetadata: metadata.Metadata{ Forge: metadata.Forge{Type: "gitea", URL: "https://gitea.com"}, - Sys: metadata.System{Name: "woodpecker", Host: "example.com", Link: "https://example.com"}, - Repo: metadata.Repo{Owner: "testUser", Name: "testRepo", Link: "https://gitea.com/testUser/testRepo", CloneURL: "https://gitea.com/testUser/testRepo.git", CloneSSHURL: "git@gitea.com:testUser/testRepo.git", Branch: "main", Private: true}, + Sys: metadata.System{Name: "woodpecker", Host: "example.com", URL: "https://example.com"}, + Repo: metadata.Repo{Owner: "testUser", Name: "testRepo", URL: "https://gitea.com/testUser/testRepo", CloneURL: "https://gitea.com/testUser/testRepo.git", CloneSSHURL: "git@gitea.com:testUser/testRepo.git", Branch: "main", Private: true}, Curr: metadata.Pipeline{Number: 3}, Prev: metadata.Pipeline{Number: 2}, Workflow: metadata.Workflow{Name: "hello"}, diff --git a/pipeline/frontend/yaml/compiler/compiler_test.go b/pipeline/frontend/yaml/compiler/compiler_test.go index eae463ffb3..9dcfa34ec2 100644 --- a/pipeline/frontend/yaml/compiler/compiler_test.go +++ b/pipeline/frontend/yaml/compiler/compiler_test.go @@ -60,7 +60,7 @@ func TestCompilerCompile(t *testing.T) { Owner: "octacat", Name: "hello-world", Private: true, - Link: "https://github.com/octocat/hello-world", + URL: "https://github.com/octocat/hello-world", CloneURL: "https://github.com/octocat/hello-world.git", }, }), diff --git a/pipeline/frontend/yaml/compiler/option.go b/pipeline/frontend/yaml/compiler/option.go index 0dc5ac5ad3..81e2442b5f 100644 --- a/pipeline/frontend/yaml/compiler/option.go +++ b/pipeline/frontend/yaml/compiler/option.go @@ -104,9 +104,9 @@ func WithWorkspace(base, path string) Option { // WithWorkspaceFromURL configures the compiler with the workspace // base and path based on the repository url. -func WithWorkspaceFromURL(base, link string) Option { +func WithWorkspaceFromURL(base, u string) Option { srcPath := "src" - parsed, err := url.Parse(link) + parsed, err := url.Parse(u) if err == nil { srcPath = path.Join(srcPath, parsed.Hostname(), parsed.Path) } diff --git a/pipeline/frontend/yaml/compiler/option_test.go b/pipeline/frontend/yaml/compiler/option_test.go index 75b3222b94..e788a971ed 100644 --- a/pipeline/frontend/yaml/compiler/option_test.go +++ b/pipeline/frontend/yaml/compiler/option_test.go @@ -115,7 +115,7 @@ func TestWithMetadata(t *testing.T) { Owner: "octacat", Name: "hello-world", Private: true, - Link: "https://github.com/octocat/hello-world", + URL: "https://github.com/octocat/hello-world", CloneURL: "https://github.com/octocat/hello-world.git", }, } @@ -129,7 +129,7 @@ func TestWithMetadata(t *testing.T) { if compiler.env["CI_REPO_NAME"] != metadata.Repo.Name { t.Errorf("WithMetadata must set CI_REPO_NAME") } - if compiler.env["CI_REPO_URL"] != metadata.Repo.Link { + if compiler.env["CI_REPO_URL"] != metadata.Repo.URL { t.Errorf("WithMetadata must set CI_REPO_URL") } if compiler.env["CI_REPO_CLONE_URL"] != metadata.Repo.CloneURL { diff --git a/pipeline/rpc/proto/woodpecker.pb.go b/pipeline/rpc/proto/woodpecker.pb.go index 85464b5dce..eb8dd2083f 100644 --- a/pipeline/rpc/proto/woodpecker.pb.go +++ b/pipeline/rpc/proto/woodpecker.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.24.4 // source: woodpecker.proto diff --git a/pipeline/stepBuilder.go b/pipeline/stepBuilder.go index 5f0677eacf..48351cf415 100644 --- a/pipeline/stepBuilder.go +++ b/pipeline/stepBuilder.go @@ -291,7 +291,7 @@ func (b *StepBuilder) toInternalRepresentation(parsed *yaml_types.Workflow, envi ), ), compiler.WithProxy(b.ProxyOpts), - compiler.WithWorkspaceFromURL("/woodpecker", b.Repo.Link), + compiler.WithWorkspaceFromURL("/woodpecker", b.Repo.URL), compiler.WithMetadata(metadata), compiler.WithTrusted(b.Repo.IsTrusted), compiler.WithNetrcOnlyTrusted(b.Repo.NetrcOnlyTrusted), diff --git a/server/api/pipeline.go b/server/api/pipeline.go index cc60767b1f..28d4f3d5db 100644 --- a/server/api/pipeline.go +++ b/server/api/pipeline.go @@ -88,7 +88,7 @@ func createTmpPipeline(event model.WebhookEvent, commitSHA string, repo *model.R Email: user.Email, // TODO: Generate proper link to commit - Link: repo.Link, + URL: repo.URL, } } diff --git a/server/ccmenu/cc.go b/server/ccmenu/cc.go index f2321cd73d..81179f9e88 100644 --- a/server/ccmenu/cc.go +++ b/server/ccmenu/cc.go @@ -43,10 +43,10 @@ type CCProject struct { WebURL string `xml:"webUrl,attr"` } -func New(r *model.Repo, b *model.Pipeline, link string) *CCProjects { +func New(r *model.Repo, b *model.Pipeline, url string) *CCProjects { proj := &CCProject{ Name: r.FullName, - WebURL: link, + WebURL: url, Activity: "Building", LastBuildStatus: "Unknown", LastBuildLabel: "Unknown", diff --git a/server/cron/cron.go b/server/cron/cron.go index c7548c8714..60708d775b 100644 --- a/server/cron/cron.go +++ b/server/cron/cron.go @@ -139,6 +139,6 @@ func CreatePipeline(ctx context.Context, store store.Store, f forge.Forge, cron Message: cron.Name, Timestamp: cron.NextExec, Sender: cron.Name, - Link: repo.Link, + URL: repo.URL, }, nil } diff --git a/server/forge/bitbucket/convert.go b/server/forge/bitbucket/convert.go index 855c7f9741..fd11bda200 100644 --- a/server/forge/bitbucket/convert.go +++ b/server/forge/bitbucket/convert.go @@ -56,7 +56,7 @@ func convertRepo(from *internal.Repo, perm *internal.RepoPerm) *model.Repo { Owner: strings.Split(from.FullName, "/")[0], Name: strings.Split(from.FullName, "/")[1], FullName: from.FullName, - Link: from.Links.HTML.Href, + URL: from.Links.HTML.Href, IsSCMPrivate: from.IsPrivate, Avatar: from.Owner.Links.Avatar.Href, SCMKind: model.SCMKind(from.Scm), @@ -171,7 +171,7 @@ func convertPullHook(from *internal.PullRequestHook) *model.Pipeline { from.PullRequest.Dest.Branch.Name, ), CloneURL: fmt.Sprintf("https://bitbucket.org/%s", from.PullRequest.Source.Repo.FullName), - Link: from.PullRequest.Links.HTML.Href, + URL: from.PullRequest.Links.HTML.Href, Branch: from.PullRequest.Dest.Branch.Name, Message: from.PullRequest.Desc, Avatar: from.Actor.Links.Avatar.Href, @@ -186,7 +186,7 @@ func convertPullHook(from *internal.PullRequestHook) *model.Pipeline { func convertPushHook(hook *internal.PushHook, change *internal.Change) *model.Pipeline { pipeline := &model.Pipeline{ Commit: change.New.Target.Hash, - Link: change.New.Target.Links.HTML.Href, + URL: change.New.Target.Links.HTML.Href, Branch: change.New.Name, Message: change.New.Target.Message, Avatar: hook.Actor.Links.Avatar.Href, diff --git a/server/forge/bitbucket/convert_test.go b/server/forge/bitbucket/convert_test.go index e63cbb6a57..08485a4146 100644 --- a/server/forge/bitbucket/convert_test.go +++ b/server/forge/bitbucket/convert_test.go @@ -65,7 +65,7 @@ func Test_helper(t *testing.T) { g.Assert(string(to.SCMKind)).Equal(from.Scm) g.Assert(to.IsSCMPrivate).Equal(from.IsPrivate) g.Assert(to.Clone).Equal(from.Links.HTML.Href) - g.Assert(to.Link).Equal(from.Links.HTML.Href) + g.Assert(to.URL).Equal(from.Links.HTML.Href) g.Assert(to.Perm.Push).IsTrue() g.Assert(to.Perm.Admin).IsFalse() }) @@ -139,7 +139,7 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Avatar).Equal(hook.Actor.Links.Avatar.Href) g.Assert(pipeline.Commit).Equal(hook.PullRequest.Dest.Commit.Hash) g.Assert(pipeline.Branch).Equal(hook.PullRequest.Dest.Branch.Name) - g.Assert(pipeline.Link).Equal(hook.PullRequest.Links.HTML.Href) + g.Assert(pipeline.URL).Equal(hook.PullRequest.Links.HTML.Href) g.Assert(pipeline.Ref).Equal("refs/heads/main") g.Assert(pipeline.Refspec).Equal("change:main") g.Assert(pipeline.CloneURL).Equal("https://bitbucket.org/baz/bar") @@ -167,7 +167,7 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Avatar).Equal(hook.Actor.Links.Avatar.Href) g.Assert(pipeline.Commit).Equal(change.New.Target.Hash) g.Assert(pipeline.Branch).Equal(change.New.Name) - g.Assert(pipeline.Link).Equal(change.New.Target.Links.HTML.Href) + g.Assert(pipeline.URL).Equal(change.New.Target.Links.HTML.Href) g.Assert(pipeline.Ref).Equal("refs/heads/main") g.Assert(pipeline.Message).Equal(change.New.Target.Message) g.Assert(pipeline.Timestamp).Equal(change.New.Target.Date.Unix()) diff --git a/server/forge/gitea/gitea_test.go b/server/forge/gitea/gitea_test.go index bf59fd7f6a..93211fb0bd 100644 --- a/server/forge/gitea/gitea_test.go +++ b/server/forge/gitea/gitea_test.go @@ -92,7 +92,7 @@ func Test_gitea(t *testing.T) { g.Assert(repo.FullName).Equal(fakeRepo.Owner + "/" + fakeRepo.Name) g.Assert(repo.IsSCMPrivate).IsTrue() g.Assert(repo.Clone).Equal("http://localhost/test_name/repo_name.git") - g.Assert(repo.Link).Equal("http://localhost/test_name/repo_name") + g.Assert(repo.URL).Equal("http://localhost/test_name/repo_name") }) g.It("Should handle a not found error", func() { _, err := c.Repo(ctx, fakeUser, "0", fakeRepoNotFound.Owner, fakeRepoNotFound.Name) diff --git a/server/forge/gitea/helper.go b/server/forge/gitea/helper.go index 700892dab7..32237c5dcc 100644 --- a/server/forge/gitea/helper.go +++ b/server/forge/gitea/helper.go @@ -43,7 +43,7 @@ func toRepo(from *gitea.Repository) *model.Repo { Owner: from.Owner.UserName, FullName: from.FullName, Avatar: avatar, - Link: from.HTMLURL, + URL: from.HTMLURL, IsSCMPrivate: from.Private || from.Owner.Visibility != gitea.VisibleTypePublic, Clone: from.CloneURL, CloneSSH: from.SSHURL, @@ -92,7 +92,7 @@ func pipelineFromPush(hook *pushHook) *model.Pipeline { Event: model.EventPush, Commit: hook.After, Ref: hook.Ref, - Link: link, + URL: link, Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"), Message: message, Avatar: avatar, @@ -131,7 +131,7 @@ func pipelineFromTag(hook *pushHook) *model.Pipeline { Event: model.EventTag, Commit: hook.Sha, Ref: fmt.Sprintf("refs/tags/%s", hook.Ref), - Link: fmt.Sprintf("%s/src/tag/%s", hook.Repo.HTMLURL, hook.Ref), + URL: fmt.Sprintf("%s/src/tag/%s", hook.Repo.HTMLURL, hook.Ref), Branch: fmt.Sprintf("refs/tags/%s", hook.Ref), Message: fmt.Sprintf("created tag %s", hook.Ref), Avatar: avatar, @@ -150,7 +150,7 @@ func pipelineFromPullRequest(hook *pullRequestHook) *model.Pipeline { pipeline := &model.Pipeline{ Event: model.EventPull, Commit: hook.PullRequest.Head.Sha, - Link: hook.PullRequest.URL, + URL: hook.PullRequest.URL, Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number), Branch: hook.PullRequest.Base.Ref, Message: hook.PullRequest.Title, diff --git a/server/forge/gitea/helper_test.go b/server/forge/gitea/helper_test.go index c318ec66c7..05584c5dd0 100644 --- a/server/forge/gitea/helper_test.go +++ b/server/forge/gitea/helper_test.go @@ -99,7 +99,7 @@ func Test_parse(t *testing.T) { g.Assert(pipeline.Event).Equal(model.EventPush) g.Assert(pipeline.Commit).Equal(hook.After) g.Assert(pipeline.Ref).Equal(hook.Ref) - g.Assert(pipeline.Link).Equal(hook.Commits[0].URL) + g.Assert(pipeline.URL).Equal(hook.Commits[0].URL) g.Assert(pipeline.Branch).Equal("main") g.Assert(pipeline.Message).Equal(hook.Commits[0].Message) g.Assert(pipeline.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87") @@ -114,7 +114,7 @@ func Test_parse(t *testing.T) { g.Assert(repo.Name).Equal(hook.Repo.Name) g.Assert(repo.Owner).Equal(hook.Repo.Owner.UserName) g.Assert(repo.FullName).Equal("gordon/hello-world") - g.Assert(repo.Link).Equal(hook.Repo.HTMLURL) + g.Assert(repo.URL).Equal(hook.Repo.HTMLURL) }) g.It("Should return a Pipeline struct from a tag hook", func() { @@ -125,7 +125,7 @@ func Test_parse(t *testing.T) { g.Assert(pipeline.Commit).Equal(hook.Sha) g.Assert(pipeline.Ref).Equal("refs/tags/v1.0.0") g.Assert(pipeline.Branch).Equal("refs/tags/v1.0.0") - g.Assert(pipeline.Link).Equal("http://gitea.golang.org/gordon/hello-world/src/tag/v1.0.0") + g.Assert(pipeline.URL).Equal("http://gitea.golang.org/gordon/hello-world/src/tag/v1.0.0") g.Assert(pipeline.Message).Equal("created tag v1.0.0") }) @@ -136,7 +136,7 @@ func Test_parse(t *testing.T) { g.Assert(pipeline.Event).Equal(model.EventPull) g.Assert(pipeline.Commit).Equal(hook.PullRequest.Head.Sha) g.Assert(pipeline.Ref).Equal("refs/pull/1/head") - g.Assert(pipeline.Link).Equal(hook.PullRequest.URL) + g.Assert(pipeline.URL).Equal(hook.PullRequest.URL) g.Assert(pipeline.Branch).Equal("main") g.Assert(pipeline.Refspec).Equal("feature/changes:main") g.Assert(pipeline.Message).Equal(hook.PullRequest.Title) @@ -151,7 +151,7 @@ func Test_parse(t *testing.T) { g.Assert(repo.Name).Equal(hook.Repo.Name) g.Assert(repo.Owner).Equal(hook.Repo.Owner.UserName) g.Assert(repo.FullName).Equal("gordon/hello-world") - g.Assert(repo.Link).Equal(hook.Repo.HTMLURL) + g.Assert(repo.URL).Equal(hook.Repo.HTMLURL) }) g.It("Should return a Perm struct from a Gitea Perm", func() { @@ -209,7 +209,7 @@ func Test_parse(t *testing.T) { g.Assert(repo.Owner).Equal(from.Owner.UserName) g.Assert(repo.Name).Equal("hello-world") g.Assert(repo.Branch).Equal("main") - g.Assert(repo.Link).Equal(from.HTMLURL) + g.Assert(repo.URL).Equal(from.HTMLURL) g.Assert(repo.Clone).Equal(from.CloneURL) g.Assert(repo.Avatar).Equal(from.Owner.AvatarURL) g.Assert(repo.IsSCMPrivate).Equal(from.Private) diff --git a/server/forge/github/convert.go b/server/forge/github/convert.go index edff3d12c5..e1e55eadae 100644 --- a/server/forge/github/convert.go +++ b/server/forge/github/convert.go @@ -86,7 +86,7 @@ func convertRepo(from *github.Repository) *model.Repo { ForgeRemoteID: model.ForgeRemoteID(fmt.Sprint(from.GetID())), Name: from.GetName(), FullName: from.GetFullName(), - Link: from.GetHTMLURL(), + URL: from.GetHTMLURL(), IsSCMPrivate: from.GetPrivate(), Clone: from.GetCloneURL(), CloneSSH: from.GetSSHURL(), @@ -146,7 +146,7 @@ func convertRepoHook(eventRepo *github.PushEventRepository) *model.Repo { Owner: eventRepo.GetOwner().GetLogin(), Name: eventRepo.GetName(), FullName: eventRepo.GetFullName(), - Link: eventRepo.GetHTMLURL(), + URL: eventRepo.GetHTMLURL(), IsSCMPrivate: eventRepo.GetPrivate(), Clone: eventRepo.GetCloneURL(), CloneSSH: eventRepo.GetSSHURL(), diff --git a/server/forge/github/convert_test.go b/server/forge/github/convert_test.go index d4f3f9cf7a..12448783b0 100644 --- a/server/forge/github/convert_test.go +++ b/server/forge/github/convert_test.go @@ -118,7 +118,7 @@ func Test_helper(t *testing.T) { g.Assert(string(to.SCMKind)).Equal("git") g.Assert(to.IsSCMPrivate).IsTrue() g.Assert(to.Clone).Equal("https://github.com/octocat/hello-world.git") - g.Assert(to.Link).Equal("https://github.com/octocat/hello-world") + g.Assert(to.URL).Equal("https://github.com/octocat/hello-world") }) g.It("should convert repository permissions", func() { @@ -174,7 +174,7 @@ func Test_helper(t *testing.T) { g.Assert(repo.Name).Equal(*from.Name) g.Assert(repo.FullName).Equal(*from.FullName) g.Assert(repo.IsSCMPrivate).Equal(*from.Private) - g.Assert(repo.Link).Equal(*from.HTMLURL) + g.Assert(repo.URL).Equal(*from.HTMLURL) g.Assert(repo.Clone).Equal(*from.CloneURL) g.Assert(repo.Branch).Equal(*from.DefaultBranch) }) @@ -239,7 +239,7 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Ref).Equal("refs/heads/main") g.Assert(pipeline.Commit).Equal(*from.Deployment.SHA) g.Assert(pipeline.Message).Equal(*from.Deployment.Description) - g.Assert(pipeline.Link).Equal(*from.Deployment.URL) + g.Assert(pipeline.URL).Equal(*from.Deployment.URL) g.Assert(pipeline.Author).Equal(*from.Sender.Login) g.Assert(pipeline.Avatar).Equal(*from.Sender.AvatarURL) }) @@ -262,7 +262,7 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Ref).Equal("refs/heads/main") g.Assert(pipeline.Commit).Equal(*from.HeadCommit.ID) g.Assert(pipeline.Message).Equal(*from.HeadCommit.Message) - g.Assert(pipeline.Link).Equal(*from.HeadCommit.URL) + g.Assert(pipeline.URL).Equal(*from.HeadCommit.URL) g.Assert(pipeline.Author).Equal(*from.Sender.Login) g.Assert(pipeline.Avatar).Equal(*from.Sender.AvatarURL) g.Assert(pipeline.Email).Equal(*from.HeadCommit.Author.Email) diff --git a/server/forge/github/github.go b/server/forge/github/github.go index 54f1dbeebc..66ecab2475 100644 --- a/server/forge/github/github.go +++ b/server/forge/github/github.go @@ -488,7 +488,7 @@ func (c *client) Status(ctx context.Context, user *model.User, repo *model.Repo, client := c.newClientToken(ctx, user.Token) if pipeline.Event == model.EventDeploy { - matches := reDeploy.FindStringSubmatch(pipeline.Link) + matches := reDeploy.FindStringSubmatch(pipeline.URL) if len(matches) != 2 { return nil } diff --git a/server/forge/github/github_test.go b/server/forge/github/github_test.go index 54f55e2f8c..1db3fa1a6d 100644 --- a/server/forge/github/github_test.go +++ b/server/forge/github/github_test.go @@ -86,7 +86,7 @@ func Test_github(t *testing.T) { g.Assert(repo.FullName).Equal(fakeRepo.FullName) g.Assert(repo.IsSCMPrivate).IsTrue() g.Assert(repo.Clone).Equal(fakeRepo.Clone) - g.Assert(repo.Link).Equal(fakeRepo.Link) + g.Assert(repo.URL).Equal(fakeRepo.URL) }) g.It("Should handle a not found error", func() { _, err := c.Repo(ctx, fakeUser, "0", fakeRepoNotFound.Owner, fakeRepoNotFound.Name) @@ -124,7 +124,7 @@ var ( Name: "Hello-World", FullName: "octocat/Hello-World", Avatar: "https://github.com/images/error/octocat_happy.gif", - Link: "https://github.com/octocat/Hello-World", + URL: "https://github.com/octocat/Hello-World", Clone: "https://github.com/octocat/Hello-World.git", IsSCMPrivate: true, } diff --git a/server/forge/github/parse.go b/server/forge/github/parse.go index 769ad6711b..90095eeed9 100644 --- a/server/forge/github/parse.go +++ b/server/forge/github/parse.go @@ -82,7 +82,7 @@ func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline, error) Event: model.EventPush, Commit: hook.GetHeadCommit().GetID(), Ref: hook.GetRef(), - Link: hook.GetHeadCommit().GetURL(), + URL: hook.GetHeadCommit().GetURL(), Branch: strings.Replace(hook.GetRef(), "refs/heads/", "", -1), Message: hook.GetHeadCommit().GetMessage(), Email: hook.GetHeadCommit().GetAuthor().GetEmail(), @@ -117,7 +117,7 @@ func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline pipeline := &model.Pipeline{ Event: model.EventDeploy, Commit: hook.GetDeployment().GetSHA(), - Link: hook.GetDeployment().GetURL(), + URL: hook.GetDeployment().GetURL(), Message: hook.GetDeployment().GetDescription(), Ref: hook.GetDeployment().GetRef(), Branch: hook.GetDeployment().GetRef(), @@ -153,7 +153,7 @@ func parsePullHook(hook *github.PullRequestEvent, merge bool) (*github.PullReque pipeline := &model.Pipeline{ Event: model.EventPull, Commit: hook.GetPullRequest().GetHead().GetSHA(), - Link: hook.GetPullRequest().GetHTMLURL(), + URL: hook.GetPullRequest().GetHTMLURL(), Ref: fmt.Sprintf(headRefs, hook.GetPullRequest().GetNumber()), Branch: hook.GetPullRequest().GetBase().GetRef(), Message: hook.GetPullRequest().GetTitle(), diff --git a/server/forge/gitlab/convert.go b/server/forge/gitlab/convert.go index e1b1a0a71d..d65f742584 100644 --- a/server/forge/gitlab/convert.go +++ b/server/forge/gitlab/convert.go @@ -41,7 +41,7 @@ func (g *GitLab) convertGitLabRepo(_repo *gitlab.Project) (*model.Repo, error) { Name: name, FullName: _repo.PathWithNamespace, Avatar: _repo.AvatarURL, - Link: _repo.WebURL, + URL: _repo.WebURL, Clone: _repo.HTTPURLToRepo, CloneSSH: _repo.SSHURLToRepo, Branch: _repo.DefaultBranch, @@ -90,7 +90,7 @@ func convertMergeRequestHook(hook *gitlab.MergeEvent, req *http.Request) (int, * } repo.ForgeRemoteID = model.ForgeRemoteID(fmt.Sprint(obj.TargetProjectID)) - repo.Link = target.WebURL + repo.URL = target.WebURL if target.GitHTTPURL != "" { repo.Clone = target.GitHTTPURL @@ -130,7 +130,7 @@ func convertMergeRequestHook(hook *gitlab.MergeEvent, req *http.Request) (int, * } pipeline.Title = obj.Title - pipeline.Link = obj.URL + pipeline.URL = obj.URL pipeline.PullRequestLabels = convertLabels(hook.Labels) return obj.IID, repo, pipeline, nil @@ -147,7 +147,7 @@ func convertPushHook(hook *gitlab.PushEvent) (*model.Repo, *model.Pipeline, erro repo.ForgeRemoteID = model.ForgeRemoteID(fmt.Sprint(hook.ProjectID)) repo.Avatar = hook.Project.AvatarURL - repo.Link = hook.Project.WebURL + repo.URL = hook.Project.WebURL repo.Clone = hook.Project.GitHTTPURL repo.CloneSSH = hook.Project.GitSSHURL repo.FullName = hook.Project.PathWithNamespace @@ -200,7 +200,7 @@ func convertTagHook(hook *gitlab.TagEvent) (*model.Repo, *model.Pipeline, error) repo.ForgeRemoteID = model.ForgeRemoteID(fmt.Sprint(hook.ProjectID)) repo.Avatar = hook.Project.AvatarURL - repo.Link = hook.Project.WebURL + repo.URL = hook.Project.WebURL repo.Clone = hook.Project.GitHTTPURL repo.CloneSSH = hook.Project.GitSSHURL repo.FullName = hook.Project.PathWithNamespace diff --git a/server/forge/mocks/forge.go b/server/forge/mocks/forge.go index e15f9fbe77..ad75c64a18 100644 --- a/server/forge/mocks/forge.go +++ b/server/forge/mocks/forge.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.36.0. DO NOT EDIT. +// Code generated by mockery v2.36.1. DO NOT EDIT. package mocks diff --git a/server/model/pipeline.go b/server/model/pipeline.go index edfbb64aa1..a9a99e66d6 100644 --- a/server/model/pipeline.go +++ b/server/model/pipeline.go @@ -46,7 +46,7 @@ type Pipeline struct { Sender string `json:"sender" xorm:"pipeline_sender"` // uses reported user for webhooks and name of cron for cron pipelines Avatar string `json:"author_avatar" xorm:"pipeline_avatar"` Email string `json:"author_email" xorm:"pipeline_email"` - Link string `json:"link_url" xorm:"pipeline_link"` + URL string `json:"url" xorm:"pipeline_url"` Reviewer string `json:"reviewed_by" xorm:"pipeline_reviewer"` Reviewed int64 `json:"reviewed_at" xorm:"pipeline_reviewed"` Workflows []*Workflow `json:"workflows,omitempty" xorm:"-"` diff --git a/server/model/repo.go b/server/model/repo.go index 46fd0fddb8..dbfab9992d 100644 --- a/server/model/repo.go +++ b/server/model/repo.go @@ -31,7 +31,7 @@ type Repo struct { Name string `json:"name" xorm:"UNIQUE(name) 'repo_name'"` FullName string `json:"full_name" xorm:"UNIQUE 'repo_full_name'"` Avatar string `json:"avatar_url,omitempty" xorm:"varchar(500) 'repo_avatar'"` - Link string `json:"link_url,omitempty" xorm:"varchar(1000) 'repo_link'"` + URL string `json:"url,omitempty" xorm:"varchar(1000) 'repo_url'"` Clone string `json:"clone_url,omitempty" xorm:"varchar(1000) 'repo_clone'"` CloneSSH string `json:"clone_url_ssh" xorm:"varchar(1000) 'repo_clone_ssh'"` Branch string `json:"default_branch,omitempty" xorm:"varchar(500) 'repo_branch'"` @@ -83,7 +83,7 @@ func (r *Repo) Update(from *Repo) { r.Name = from.Name r.FullName = from.FullName r.Avatar = from.Avatar - r.Link = from.Link + r.URL = from.URL r.SCMKind = from.SCMKind if len(from.Clone) > 0 { r.Clone = from.Clone diff --git a/server/store/datastore/migration/027_link_to_url.go b/server/store/datastore/migration/027_link_to_url.go new file mode 100644 index 0000000000..7f9328383b --- /dev/null +++ b/server/store/datastore/migration/027_link_to_url.go @@ -0,0 +1,31 @@ +// Copyright 2023 Woodpecker Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package migration + +import ( + "xorm.io/xorm" +) + +var renameLinkToURL = task{ + name: "rename-link-to-url", + required: true, + fn: func(sess *xorm.Session) (err error) { + if err := renameColumn(sess, "pipelines", "pipeline_link", "pipeline_url"); err != nil { + return err + } + + return renameColumn(sess, "repos", "repo_link", "repo_url") + }, +} diff --git a/server/store/mocks/store.go b/server/store/mocks/store.go index a5c3e1d20f..77a826676b 100644 --- a/server/store/mocks/store.go +++ b/server/store/mocks/store.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.36.0. DO NOT EDIT. +// Code generated by mockery v2.36.1. DO NOT EDIT. package mocks diff --git a/web/src/lib/api/types/pipeline.ts b/web/src/lib/api/types/pipeline.ts index 9301904472..bf081f0f25 100644 --- a/web/src/lib/api/types/pipeline.ts +++ b/web/src/lib/api/types/pipeline.ts @@ -76,9 +76,8 @@ export type Pipeline = { // email for the author of the commit. author_email: string; - // The link to view the repository. - // This link will point to the repository state associated with the pipeline's commit. - link_url: string; + // This url will point to the repository state associated with the pipeline's commit. + url: string; signed: boolean; diff --git a/web/src/lib/api/types/repo.ts b/web/src/lib/api/types/repo.ts index 9241fc0adf..e9ca70b193 100644 --- a/web/src/lib/api/types/repo.ts +++ b/web/src/lib/api/types/repo.ts @@ -29,8 +29,8 @@ export type Repo = { // The url for the avatar image. avatar_url: string; - // The link to view the repository. - link_url: string; + // The url to view the repository. + url: string; // The url used to clone the repository. clone_url: string; diff --git a/woodpecker-go/woodpecker/types.go b/woodpecker-go/woodpecker/types.go index 6117a08142..f999bd8888 100644 --- a/woodpecker-go/woodpecker/types.go +++ b/woodpecker-go/woodpecker/types.go @@ -33,7 +33,7 @@ type ( Name string `json:"name"` FullName string `json:"full_name"` Avatar string `json:"avatar_url,omitempty"` - Link string `json:"link_url,omitempty"` + URL string `json:"url,omitempty"` Clone string `json:"clone_url,omitempty"` DefaultBranch string `json:"default_branch,omitempty"` SCMKind string `json:"scm,omitempty"` @@ -93,7 +93,7 @@ type ( Author string `json:"author"` Avatar string `json:"author_avatar"` Email string `json:"author_email"` - Link string `json:"link_url"` + URL string `json:"url"` Reviewer string `json:"reviewed_by"` Reviewed int64 `json:"reviewed_at"` Workflows []*Workflow `json:"workflows,omitempty"` From a4d4f2056300cad893deedc841b4342f03e6734d Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 12 Nov 2023 11:23:02 +0100 Subject: [PATCH 3/9] format and rm useless json tags --- pipeline/frontend/metadata.go | 6 +- pipeline/frontend/metadata/types.go | 118 ++++++++++++++-------------- server/cron/cron.go | 2 +- server/forge/bitbucket/convert.go | 6 +- server/forge/gitea/helper.go | 8 +- server/forge/github/convert.go | 4 +- server/forge/github/github_test.go | 2 +- server/forge/github/parse.go | 6 +- server/forge/gitlab/convert.go | 2 +- server/model/pipeline.go | 2 +- server/model/repo.go | 2 +- woodpecker-go/woodpecker/types.go | 4 +- 12 files changed, 81 insertions(+), 81 deletions(-) diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index 4bc7efb179..ac85e68927 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -59,7 +59,7 @@ func MetadataFromStruct(forge metadata.ServerForge, repo *model.Repo, pipeline, Name: repo.Name, Owner: repo.Owner, RemoteID: fmt.Sprint(repo.ForgeRemoteID), - URL: repo.URL, + URL: repo.URL, CloneURL: repo.Clone, CloneSSHURL: repo.CloneSSH, Private: repo.IsSCMPrivate, @@ -94,7 +94,7 @@ func MetadataFromStruct(forge metadata.ServerForge, repo *model.Repo, pipeline, Step: metadata.Step{}, Sys: metadata.System{ Name: "woodpecker", - URL: sysURL, + URL: sysURL, Host: host, Platform: "", // will be set by pipeline platform option or by agent Version: version.Version, @@ -126,7 +126,7 @@ func metadataPipelineFromModelPipeline(pipeline *model.Pipeline, includeParent b Finished: pipeline.Finished, Status: string(pipeline.Status), Event: string(pipeline.Event), - URL: pipeline.URL, + URL: pipeline.URL, Target: pipeline.Deploy, Commit: metadata.Commit{ Sha: pipeline.Commit, diff --git a/pipeline/frontend/metadata/types.go b/pipeline/frontend/metadata/types.go index 7f46e52c62..4f54c0fdbb 100644 --- a/pipeline/frontend/metadata/types.go +++ b/pipeline/frontend/metadata/types.go @@ -17,101 +17,101 @@ package metadata type ( // Metadata defines runtime m. Metadata struct { - ID string `json:"id,omitempty"` - Repo Repo `json:"repo,omitempty"` - Curr Pipeline `json:"curr,omitempty"` - Prev Pipeline `json:"prev,omitempty"` - Workflow Workflow `json:"workflow,omitempty"` - Step Step `json:"step,omitempty"` - Sys System `json:"sys,omitempty"` - Forge Forge `json:"forge,omitempty"` + ID string + Repo Repo + Curr Pipeline + Prev Pipeline + Workflow Workflow + Step Step + Sys System + Forge Forge } // Repo defines runtime metadata for a repository. Repo struct { - ID int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Owner string `json:"owner,omitempty"` - RemoteID string `json:"remote_id,omitempty"` - URL string `json:"link,omitempty"` - CloneURL string `json:"clone_url,omitempty"` - CloneSSHURL string `json:"clone_url_ssh,omitempty"` - Private bool `json:"private,omitempty"` - Secrets []Secret `json:"secrets,omitempty"` - Branch string `json:"default_branch,omitempty"` - Trusted bool `json:"trusted,omitempty"` + ID int64 + Name string + Owner string + RemoteID string + URL string + CloneURL string + CloneSSHURL string + Private bool + Secrets []Secret + Branch string + Trusted bool } // Pipeline defines runtime metadata for a pipeline. Pipeline struct { - Number int64 `json:"number,omitempty"` - Created int64 `json:"created,omitempty"` - Started int64 `json:"started,omitempty"` - Finished int64 `json:"finished,omitempty"` - Timeout int64 `json:"timeout,omitempty"` - Status string `json:"status,omitempty"` - Event string `json:"event,omitempty"` - URL string `json:"link,omitempty"` - Target string `json:"target,omitempty"` - Trusted bool `json:"trusted,omitempty"` - Commit Commit `json:"commit,omitempty"` - Parent int64 `json:"parent,omitempty"` - Cron string `json:"cron,omitempty"` + Number int64 + Created int64 + Started int64 + Finished int64 + Timeout int64 + Status string + Event string + URL string + Target string + Trusted bool + Commit Commit + Parent int64 + Cron string } // Commit defines runtime metadata for a commit. Commit struct { - Sha string `json:"sha,omitempty"` - Ref string `json:"ref,omitempty"` - Refspec string `json:"refspec,omitempty"` - Branch string `json:"branch,omitempty"` - Message string `json:"message,omitempty"` - Author Author `json:"author,omitempty"` - ChangedFiles []string `json:"changed_files,omitempty"` - PullRequestLabels []string `json:"labels,omitempty"` + Sha string + Ref string + Refspec string + Branch string + Message string + Author Author + ChangedFiles []string + PullRequestLabels []string } // Author defines runtime metadata for a commit author. Author struct { - Name string `json:"name,omitempty"` - Email string `json:"email,omitempty"` - Avatar string `json:"avatar,omitempty"` + Name string + Email string + Avatar string } // Workflow defines runtime metadata for a workflow. Workflow struct { - Name string `json:"name,omitempty"` - Number int `json:"number,omitempty"` - Matrix map[string]string `json:"matrix,omitempty"` + Name string + Number int + Matrix map[string]string } // Step defines runtime metadata for a step. Step struct { - Name string `json:"name,omitempty"` - Number int `json:"number,omitempty"` + Name string + Number int } // Secret defines a runtime secret Secret struct { - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - Mount string `json:"mount,omitempty"` - Mask bool `json:"mask,omitempty"` + Name string + Value string + Mount string + Mask bool } // System defines runtime metadata for a ci/cd system. System struct { - Name string `json:"name,omitempty"` - Host string `json:"host,omitempty"` - URL string `json:"link,omitempty"` - Platform string `json:"arch,omitempty"` - Version string `json:"version,omitempty"` + Name string + Host string + URL string + Platform string + Version string } // Forge defines runtime metadata about the forge that host the repo Forge struct { - Type string `json:"type,omitempty"` - URL string `json:"url,omitempty"` + Type string + URL string } // ServerForge represent the needed func of a server forge to get its metadata diff --git a/server/cron/cron.go b/server/cron/cron.go index 60708d775b..53c674b578 100644 --- a/server/cron/cron.go +++ b/server/cron/cron.go @@ -139,6 +139,6 @@ func CreatePipeline(ctx context.Context, store store.Store, f forge.Forge, cron Message: cron.Name, Timestamp: cron.NextExec, Sender: cron.Name, - URL: repo.URL, + URL: repo.URL, }, nil } diff --git a/server/forge/bitbucket/convert.go b/server/forge/bitbucket/convert.go index fd11bda200..9a6953e4f7 100644 --- a/server/forge/bitbucket/convert.go +++ b/server/forge/bitbucket/convert.go @@ -56,7 +56,7 @@ func convertRepo(from *internal.Repo, perm *internal.RepoPerm) *model.Repo { Owner: strings.Split(from.FullName, "/")[0], Name: strings.Split(from.FullName, "/")[1], FullName: from.FullName, - URL: from.Links.HTML.Href, + URL: from.Links.HTML.Href, IsSCMPrivate: from.IsPrivate, Avatar: from.Owner.Links.Avatar.Href, SCMKind: model.SCMKind(from.Scm), @@ -171,7 +171,7 @@ func convertPullHook(from *internal.PullRequestHook) *model.Pipeline { from.PullRequest.Dest.Branch.Name, ), CloneURL: fmt.Sprintf("https://bitbucket.org/%s", from.PullRequest.Source.Repo.FullName), - URL: from.PullRequest.Links.HTML.Href, + URL: from.PullRequest.Links.HTML.Href, Branch: from.PullRequest.Dest.Branch.Name, Message: from.PullRequest.Desc, Avatar: from.Actor.Links.Avatar.Href, @@ -186,7 +186,7 @@ func convertPullHook(from *internal.PullRequestHook) *model.Pipeline { func convertPushHook(hook *internal.PushHook, change *internal.Change) *model.Pipeline { pipeline := &model.Pipeline{ Commit: change.New.Target.Hash, - URL: change.New.Target.Links.HTML.Href, + URL: change.New.Target.Links.HTML.Href, Branch: change.New.Name, Message: change.New.Target.Message, Avatar: hook.Actor.Links.Avatar.Href, diff --git a/server/forge/gitea/helper.go b/server/forge/gitea/helper.go index 32237c5dcc..be9885ad3b 100644 --- a/server/forge/gitea/helper.go +++ b/server/forge/gitea/helper.go @@ -43,7 +43,7 @@ func toRepo(from *gitea.Repository) *model.Repo { Owner: from.Owner.UserName, FullName: from.FullName, Avatar: avatar, - URL: from.HTMLURL, + URL: from.HTMLURL, IsSCMPrivate: from.Private || from.Owner.Visibility != gitea.VisibleTypePublic, Clone: from.CloneURL, CloneSSH: from.SSHURL, @@ -92,7 +92,7 @@ func pipelineFromPush(hook *pushHook) *model.Pipeline { Event: model.EventPush, Commit: hook.After, Ref: hook.Ref, - URL: link, + URL: link, Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"), Message: message, Avatar: avatar, @@ -131,7 +131,7 @@ func pipelineFromTag(hook *pushHook) *model.Pipeline { Event: model.EventTag, Commit: hook.Sha, Ref: fmt.Sprintf("refs/tags/%s", hook.Ref), - URL: fmt.Sprintf("%s/src/tag/%s", hook.Repo.HTMLURL, hook.Ref), + URL: fmt.Sprintf("%s/src/tag/%s", hook.Repo.HTMLURL, hook.Ref), Branch: fmt.Sprintf("refs/tags/%s", hook.Ref), Message: fmt.Sprintf("created tag %s", hook.Ref), Avatar: avatar, @@ -150,7 +150,7 @@ func pipelineFromPullRequest(hook *pullRequestHook) *model.Pipeline { pipeline := &model.Pipeline{ Event: model.EventPull, Commit: hook.PullRequest.Head.Sha, - URL: hook.PullRequest.URL, + URL: hook.PullRequest.URL, Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number), Branch: hook.PullRequest.Base.Ref, Message: hook.PullRequest.Title, diff --git a/server/forge/github/convert.go b/server/forge/github/convert.go index e1e55eadae..9660674d4b 100644 --- a/server/forge/github/convert.go +++ b/server/forge/github/convert.go @@ -86,7 +86,7 @@ func convertRepo(from *github.Repository) *model.Repo { ForgeRemoteID: model.ForgeRemoteID(fmt.Sprint(from.GetID())), Name: from.GetName(), FullName: from.GetFullName(), - URL: from.GetHTMLURL(), + URL: from.GetHTMLURL(), IsSCMPrivate: from.GetPrivate(), Clone: from.GetCloneURL(), CloneSSH: from.GetSSHURL(), @@ -146,7 +146,7 @@ func convertRepoHook(eventRepo *github.PushEventRepository) *model.Repo { Owner: eventRepo.GetOwner().GetLogin(), Name: eventRepo.GetName(), FullName: eventRepo.GetFullName(), - URL: eventRepo.GetHTMLURL(), + URL: eventRepo.GetHTMLURL(), IsSCMPrivate: eventRepo.GetPrivate(), Clone: eventRepo.GetCloneURL(), CloneSSH: eventRepo.GetSSHURL(), diff --git a/server/forge/github/github_test.go b/server/forge/github/github_test.go index 1db3fa1a6d..9150d8e75a 100644 --- a/server/forge/github/github_test.go +++ b/server/forge/github/github_test.go @@ -124,7 +124,7 @@ var ( Name: "Hello-World", FullName: "octocat/Hello-World", Avatar: "https://github.com/images/error/octocat_happy.gif", - URL: "https://github.com/octocat/Hello-World", + URL: "https://github.com/octocat/Hello-World", Clone: "https://github.com/octocat/Hello-World.git", IsSCMPrivate: true, } diff --git a/server/forge/github/parse.go b/server/forge/github/parse.go index 90095eeed9..0209d90b42 100644 --- a/server/forge/github/parse.go +++ b/server/forge/github/parse.go @@ -82,7 +82,7 @@ func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline, error) Event: model.EventPush, Commit: hook.GetHeadCommit().GetID(), Ref: hook.GetRef(), - URL: hook.GetHeadCommit().GetURL(), + URL: hook.GetHeadCommit().GetURL(), Branch: strings.Replace(hook.GetRef(), "refs/heads/", "", -1), Message: hook.GetHeadCommit().GetMessage(), Email: hook.GetHeadCommit().GetAuthor().GetEmail(), @@ -117,7 +117,7 @@ func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline pipeline := &model.Pipeline{ Event: model.EventDeploy, Commit: hook.GetDeployment().GetSHA(), - URL: hook.GetDeployment().GetURL(), + URL: hook.GetDeployment().GetURL(), Message: hook.GetDeployment().GetDescription(), Ref: hook.GetDeployment().GetRef(), Branch: hook.GetDeployment().GetRef(), @@ -153,7 +153,7 @@ func parsePullHook(hook *github.PullRequestEvent, merge bool) (*github.PullReque pipeline := &model.Pipeline{ Event: model.EventPull, Commit: hook.GetPullRequest().GetHead().GetSHA(), - URL: hook.GetPullRequest().GetHTMLURL(), + URL: hook.GetPullRequest().GetHTMLURL(), Ref: fmt.Sprintf(headRefs, hook.GetPullRequest().GetNumber()), Branch: hook.GetPullRequest().GetBase().GetRef(), Message: hook.GetPullRequest().GetTitle(), diff --git a/server/forge/gitlab/convert.go b/server/forge/gitlab/convert.go index d65f742584..73658126d2 100644 --- a/server/forge/gitlab/convert.go +++ b/server/forge/gitlab/convert.go @@ -41,7 +41,7 @@ func (g *GitLab) convertGitLabRepo(_repo *gitlab.Project) (*model.Repo, error) { Name: name, FullName: _repo.PathWithNamespace, Avatar: _repo.AvatarURL, - URL: _repo.WebURL, + URL: _repo.WebURL, Clone: _repo.HTTPURLToRepo, CloneSSH: _repo.SSHURLToRepo, Branch: _repo.DefaultBranch, diff --git a/server/model/pipeline.go b/server/model/pipeline.go index a9a99e66d6..698a78b15f 100644 --- a/server/model/pipeline.go +++ b/server/model/pipeline.go @@ -46,7 +46,7 @@ type Pipeline struct { Sender string `json:"sender" xorm:"pipeline_sender"` // uses reported user for webhooks and name of cron for cron pipelines Avatar string `json:"author_avatar" xorm:"pipeline_avatar"` Email string `json:"author_email" xorm:"pipeline_email"` - URL string `json:"url" xorm:"pipeline_url"` + URL string `json:"url" xorm:"pipeline_url"` Reviewer string `json:"reviewed_by" xorm:"pipeline_reviewer"` Reviewed int64 `json:"reviewed_at" xorm:"pipeline_reviewed"` Workflows []*Workflow `json:"workflows,omitempty" xorm:"-"` diff --git a/server/model/repo.go b/server/model/repo.go index dbfab9992d..6780ae3a3e 100644 --- a/server/model/repo.go +++ b/server/model/repo.go @@ -31,7 +31,7 @@ type Repo struct { Name string `json:"name" xorm:"UNIQUE(name) 'repo_name'"` FullName string `json:"full_name" xorm:"UNIQUE 'repo_full_name'"` Avatar string `json:"avatar_url,omitempty" xorm:"varchar(500) 'repo_avatar'"` - URL string `json:"url,omitempty" xorm:"varchar(1000) 'repo_url'"` + URL string `json:"url,omitempty" xorm:"varchar(1000) 'repo_url'"` Clone string `json:"clone_url,omitempty" xorm:"varchar(1000) 'repo_clone'"` CloneSSH string `json:"clone_url_ssh" xorm:"varchar(1000) 'repo_clone_ssh'"` Branch string `json:"default_branch,omitempty" xorm:"varchar(500) 'repo_branch'"` diff --git a/woodpecker-go/woodpecker/types.go b/woodpecker-go/woodpecker/types.go index f999bd8888..371959e032 100644 --- a/woodpecker-go/woodpecker/types.go +++ b/woodpecker-go/woodpecker/types.go @@ -33,7 +33,7 @@ type ( Name string `json:"name"` FullName string `json:"full_name"` Avatar string `json:"avatar_url,omitempty"` - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` Clone string `json:"clone_url,omitempty"` DefaultBranch string `json:"default_branch,omitempty"` SCMKind string `json:"scm,omitempty"` @@ -93,7 +93,7 @@ type ( Author string `json:"author"` Avatar string `json:"author_avatar"` Email string `json:"author_email"` - URL string `json:"url"` + URL string `json:"url"` Reviewer string `json:"reviewed_by"` Reviewed int64 `json:"reviewed_at"` Workflows []*Workflow `json:"workflows,omitempty"` From 302b63e942ae554fc71324efcb81208db6f1cfd0 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 12 Nov 2023 11:30:19 +0100 Subject: [PATCH 4/9] more renaming --- cli/repo/repo_info.go | 2 +- docs/docs/91-migrations.md | 1 + pipeline/frontend/metadata_test.go | 6 +++--- pipeline/stepBuilder.go | 4 ++-- pipeline/stepBuilder_test.go | 24 ++++++++++++------------ server/api/pipeline.go | 2 +- server/api/repo.go | 16 ++++++++-------- server/forge/bitbucket/bitbucket.go | 2 +- server/forge/common/status.go | 2 +- server/forge/gitea/gitea.go | 2 +- server/forge/github/github.go | 4 ++-- server/forge/gitlab/gitlab.go | 2 +- server/pipeline/items.go | 2 +- 13 files changed, 35 insertions(+), 34 deletions(-) diff --git a/cli/repo/repo_info.go b/cli/repo/repo_info.go index 09ec9e1271..148fc1035b 100644 --- a/cli/repo/repo_info.go +++ b/cli/repo/repo_info.go @@ -60,7 +60,7 @@ func repoInfo(c *cli.Context) error { // template for repo information var tmplRepoInfo = `Owner: {{ .Owner }} Repo: {{ .Name }} -Link: {{ .Link }} +URL: {{ .URL }} Config path: {{ .Config }} Visibility: {{ .Visibility }} Private: {{ .IsSCMPrivate }} diff --git a/docs/docs/91-migrations.md b/docs/docs/91-migrations.md index 93aee0012d..11634ccafa 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -12,6 +12,7 @@ Some versions need some changes to the server configuration or the pipeline conf - Removed `ssh` backend. Use an agent directly on the SSH machine using the `local` backend. - Removed `/hook` and `/stream` API paths in favor of `/api/(hook|stream)`. You may need to use the "Repair repository" button in the repo settings or "Repair all" in the admin settings to recreate the forge hook. - Removed `WOODPECKER_DOCS` config variable +- Renamed `link` to `url` (including all API fields) ## 1.0.0 diff --git a/pipeline/frontend/metadata_test.go b/pipeline/frontend/metadata_test.go index 0d73d10e56..0ed610d305 100644 --- a/pipeline/frontend/metadata_test.go +++ b/pipeline/frontend/metadata_test.go @@ -62,7 +62,7 @@ func TestMetadataFromStruct(t *testing.T) { repo *model.Repo pipeline, last *model.Pipeline workflow *model.Workflow - link string + sysURL string expectedMetadata metadata.Metadata expectedEnviron map[string]string }{ @@ -92,7 +92,7 @@ func TestMetadataFromStruct(t *testing.T) { pipeline: &model.Pipeline{Number: 3}, last: &model.Pipeline{Number: 2}, workflow: &model.Workflow{Name: "hello"}, - link: "https://example.com", + sysURL: "https://example.com", expectedMetadata: metadata.Metadata{ Forge: metadata.Forge{Type: "gitea", URL: "https://gitea.com"}, Sys: metadata.System{Name: "woodpecker", Host: "example.com", URL: "https://example.com"}, @@ -122,7 +122,7 @@ func TestMetadataFromStruct(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - result := frontend.MetadataFromStruct(testCase.forge, testCase.repo, testCase.pipeline, testCase.last, testCase.workflow, testCase.link) + result := frontend.MetadataFromStruct(testCase.forge, testCase.repo, testCase.pipeline, testCase.last, testCase.workflow, testCase.sysURL) assert.EqualValues(t, testCase.expectedMetadata, result) assert.EqualValues(t, testCase.expectedEnviron, result.Environ()) }) diff --git a/pipeline/stepBuilder.go b/pipeline/stepBuilder.go index 48351cf415..494738ad14 100644 --- a/pipeline/stepBuilder.go +++ b/pipeline/stepBuilder.go @@ -48,7 +48,7 @@ type StepBuilder struct { Netrc *model.Netrc Secs []*model.Secret Regs []*model.Registry - Link string + Host string Yamls []*forge_types.FileMeta Envs map[string]string Forge metadata.ServerForge @@ -117,7 +117,7 @@ func (b *StepBuilder) Build() (items []*Item, errorsAndWarnings error) { } func (b *StepBuilder) genItemForWorkflow(workflow *model.Workflow, axis matrix.Axis, data string) (item *Item, errorsAndWarnings error) { - workflowMetadata := frontend.MetadataFromStruct(b.Forge, b.Repo, b.Curr, b.Last, workflow, b.Link) + workflowMetadata := frontend.MetadataFromStruct(b.Forge, b.Repo, b.Curr, b.Last, workflow, b.Host) environ := b.environmentVariables(workflowMetadata, axis) // add global environment variables for substituting diff --git a/pipeline/stepBuilder_test.go b/pipeline/stepBuilder_test.go index a4683dad05..e171677c40 100644 --- a/pipeline/stepBuilder_test.go +++ b/pipeline/stepBuilder_test.go @@ -44,7 +44,7 @@ func TestGlobalEnvsubst(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Data: []byte(` version: 1 @@ -81,7 +81,7 @@ func TestMissingGlobalEnvsubst(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Data: []byte(` version: 1 @@ -115,7 +115,7 @@ bbb`, Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Data: []byte(` version: 1 @@ -154,7 +154,7 @@ func TestMultiPipeline(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Data: []byte(` version: 1 @@ -191,7 +191,7 @@ func TestDependsOn(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Name: "lint", Data: []byte(` version: 1 @@ -241,7 +241,7 @@ func TestRunsOn(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Data: []byte(` version: 1 @@ -279,7 +279,7 @@ func TestPipelineName(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Name: ".woodpecker/lint.yml", Data: []byte(` version: 1 @@ -317,7 +317,7 @@ func TestBranchFilter(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Data: []byte(` version: 1 @@ -358,7 +358,7 @@ func TestRootWhenFilter(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Data: []byte(` version: 1 @@ -410,7 +410,7 @@ func TestZeroSteps(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Data: []byte(` version: 1 @@ -446,7 +446,7 @@ func TestZeroStepsAsMultiPipelineDeps(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Name: "zerostep", Data: []byte(` version: 1 @@ -498,7 +498,7 @@ func TestZeroStepsAsMultiPipelineTransitiveDeps(t *testing.T) { Netrc: &model.Netrc{}, Secs: []*model.Secret{}, Regs: []*model.Registry{}, - Link: "", + Host: "", Yamls: []*forge_types.FileMeta{ {Name: "zerostep", Data: []byte(` version: 1 diff --git a/server/api/pipeline.go b/server/api/pipeline.go index 28d4f3d5db..90ad09cb93 100644 --- a/server/api/pipeline.go +++ b/server/api/pipeline.go @@ -87,7 +87,7 @@ func createTmpPipeline(event model.WebhookEvent, commitSHA string, repo *model.R Author: user.Login, Email: user.Email, - // TODO: Generate proper link to commit + // TODO: Generate proper URL to commit URL: repo.URL, } } diff --git a/server/api/repo.go b/server/api/repo.go index 4530b54e0f..96949cf6a7 100644 --- a/server/api/repo.go +++ b/server/api/repo.go @@ -112,7 +112,7 @@ func PostRepo(c *gin.Context) { return } - link := fmt.Sprintf( + hookURL := fmt.Sprintf( "%s/api/hook?access_token=%s", server.Config.Server.WebhookHost, sig, @@ -143,7 +143,7 @@ func PostRepo(c *gin.Context) { repo.OrgID = org.ID - err = forge.Activate(c, user, repo, link) + err = forge.Activate(c, user, repo, hookURL) if err != nil { c.String(http.StatusInternalServerError, err.Error()) return @@ -478,9 +478,9 @@ func MoveRepo(c *gin.Context) { return } - // reconstruct the link + // reconstruct the hook url host := server.Config.Server.WebhookHost - link := fmt.Sprintf( + hookURL := fmt.Sprintf( "%s/api/hook?access_token=%s", host, sig, @@ -489,7 +489,7 @@ func MoveRepo(c *gin.Context) { if err := forge.Deactivate(c, user, repo, host); err != nil { log.Trace().Err(err).Msgf("deactivate repo '%s' for move to activate later, got an error", repo.FullName) } - if err := forge.Activate(c, user, repo, link); err != nil { + if err := forge.Activate(c, user, repo, hookURL); err != nil { c.String(http.StatusInternalServerError, err.Error()) return } @@ -566,9 +566,9 @@ func repairRepo(c *gin.Context, repo *model.Repo, withPerms bool) { return } - // reconstruct the link + // reconstruct the hook url host := server.Config.Server.WebhookHost - link := fmt.Sprintf( + hookURL := fmt.Sprintf( "%s/api/hook?access_token=%s", host, sig, @@ -608,7 +608,7 @@ func repairRepo(c *gin.Context, repo *model.Repo, withPerms bool) { if err := forge.Deactivate(c, user, repo, host); err != nil { log.Trace().Err(err).Msgf("deactivate repo '%s' to repair failed", repo.FullName) } - if err := forge.Activate(c, user, repo, link); err != nil { + if err := forge.Activate(c, user, repo, hookURL); err != nil { c.String(http.StatusInternalServerError, err.Error()) return } diff --git a/server/forge/bitbucket/bitbucket.go b/server/forge/bitbucket/bitbucket.go index a6d18327dc..e4c632e510 100644 --- a/server/forge/bitbucket/bitbucket.go +++ b/server/forge/bitbucket/bitbucket.go @@ -283,7 +283,7 @@ func (c *config) Status(ctx context.Context, user *model.User, repo *model.Repo, State: convertStatus(pipeline.Status), Desc: common.GetPipelineStatusDescription(pipeline.Status), Key: "Woodpecker", - URL: common.GetPipelineStatusLink(repo, pipeline, nil), + URL: common.GetPipelineStatusURL(repo, pipeline, nil), } return c.newClient(ctx, user).CreateStatus(repo.Owner, repo.Name, pipeline.Commit, &status) } diff --git a/server/forge/common/status.go b/server/forge/common/status.go index a5b69fbf0d..1c6921cd4d 100644 --- a/server/forge/common/status.go +++ b/server/forge/common/status.go @@ -77,7 +77,7 @@ func GetPipelineStatusDescription(status model.StatusValue) string { } } -func GetPipelineStatusLink(repo *model.Repo, pipeline *model.Pipeline, workflow *model.Workflow) string { +func GetPipelineStatusURL(repo *model.Repo, pipeline *model.Pipeline, workflow *model.Workflow) string { if workflow == nil { return fmt.Sprintf("%s/repos/%d/pipeline/%d", server.Config.Server.Host, repo.ID, pipeline.Number) } diff --git a/server/forge/gitea/gitea.go b/server/forge/gitea/gitea.go index b8db0f93fa..c6e120bf22 100644 --- a/server/forge/gitea/gitea.go +++ b/server/forge/gitea/gitea.go @@ -339,7 +339,7 @@ func (c *Gitea) Status(ctx context.Context, user *model.User, repo *model.Repo, pipeline.Commit, gitea.CreateStatusOption{ State: getStatus(workflow.State), - TargetURL: common.GetPipelineStatusLink(repo, pipeline, workflow), + TargetURL: common.GetPipelineStatusURL(repo, pipeline, workflow), Description: common.GetPipelineStatusDescription(workflow.State), Context: common.GetPipelineStatusContext(repo, pipeline, workflow), }, diff --git a/server/forge/github/github.go b/server/forge/github/github.go index 66ecab2475..a88a851cbf 100644 --- a/server/forge/github/github.go +++ b/server/forge/github/github.go @@ -497,7 +497,7 @@ func (c *client) Status(ctx context.Context, user *model.User, repo *model.Repo, _, _, err := client.Repositories.CreateDeploymentStatus(ctx, repo.Owner, repo.Name, int64(id), &github.DeploymentStatusRequest{ State: github.String(convertStatus(pipeline.Status)), Description: github.String(common.GetPipelineStatusDescription(pipeline.Status)), - LogURL: github.String(common.GetPipelineStatusLink(repo, pipeline, nil)), + LogURL: github.String(common.GetPipelineStatusURL(repo, pipeline, nil)), }) return err } @@ -506,7 +506,7 @@ func (c *client) Status(ctx context.Context, user *model.User, repo *model.Repo, Context: github.String(common.GetPipelineStatusContext(repo, pipeline, workflow)), State: github.String(convertStatus(workflow.State)), Description: github.String(common.GetPipelineStatusDescription(workflow.State)), - TargetURL: github.String(common.GetPipelineStatusLink(repo, pipeline, workflow)), + TargetURL: github.String(common.GetPipelineStatusURL(repo, pipeline, workflow)), }) return err } diff --git a/server/forge/gitlab/gitlab.go b/server/forge/gitlab/gitlab.go index 4db7bbcbf7..c247acbf0b 100644 --- a/server/forge/gitlab/gitlab.go +++ b/server/forge/gitlab/gitlab.go @@ -410,7 +410,7 @@ func (g *GitLab) Status(ctx context.Context, user *model.User, repo *model.Repo, _, _, err = client.Commits.SetCommitStatus(_repo.ID, pipeline.Commit, &gitlab.SetCommitStatusOptions{ State: getStatus(workflow.State), Description: gitlab.String(common.GetPipelineStatusDescription(workflow.State)), - TargetURL: gitlab.String(common.GetPipelineStatusLink(repo, pipeline, workflow)), + TargetURL: gitlab.String(common.GetPipelineStatusURL(repo, pipeline, workflow)), Context: gitlab.String(common.GetPipelineStatusContext(repo, pipeline, workflow)), }, gitlab.WithContext(ctx)) diff --git a/server/pipeline/items.go b/server/pipeline/items.go index 435ccd5e96..94307d028c 100644 --- a/server/pipeline/items.go +++ b/server/pipeline/items.go @@ -74,7 +74,7 @@ func parsePipeline(store store.Store, currentPipeline *model.Pipeline, user *mod Secs: secs, Regs: regs, Envs: envs, - Link: server.Config.Server.Host, + Host: server.Config.Server.Host, Yamls: yamls, Forge: server.Config.Services.Forge, ProxyOpts: compiler.ProxyOptions{ From 84d9c0d5a38f58f13ff61a2974c40651a933fcb2 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 12 Nov 2023 11:37:48 +0100 Subject: [PATCH 5/9] rename some to `ForgeURL` --- cli/exec/metadata.go | 6 ++--- cli/repo/repo_info.go | 2 +- pipeline/frontend/metadata.go | 4 +-- pipeline/frontend/metadata/environment.go | 10 +++---- pipeline/frontend/metadata/types.go | 4 +-- pipeline/frontend/metadata_test.go | 8 +++--- .../frontend/yaml/compiler/compiler_test.go | 2 +- .../frontend/yaml/compiler/option_test.go | 4 +-- pipeline/stepBuilder.go | 2 +- server/api/pipeline.go | 2 +- server/cron/cron.go | 2 +- server/forge/bitbucket/convert.go | 6 ++--- server/forge/bitbucket/convert_test.go | 6 ++--- server/forge/gitea/gitea_test.go | 2 +- server/forge/gitea/helper.go | 26 +++++++++---------- server/forge/gitea/helper_test.go | 12 ++++----- server/forge/github/convert.go | 4 +-- server/forge/github/convert_test.go | 8 +++--- server/forge/github/github.go | 2 +- server/forge/github/github_test.go | 4 +-- server/forge/github/parse.go | 24 ++++++++--------- server/forge/gitlab/convert.go | 10 +++---- server/model/pipeline.go | 2 +- server/model/repo.go | 4 +-- .../datastore/migration/027_link_to_url.go | 4 +-- server/store/datastore/migration/migration.go | 1 + .../repo/pipeline/PipelineStepList.vue | 4 +-- web/src/lib/api/types/pipeline.ts | 2 +- web/src/lib/api/types/repo.ts | 2 +- web/src/views/repo/RepoWrapper.vue | 2 +- web/src/views/repo/pipeline/Pipeline.vue | 2 +- woodpecker-go/woodpecker/types.go | 4 +-- 32 files changed, 89 insertions(+), 88 deletions(-) diff --git a/cli/exec/metadata.go b/cli/exec/metadata.go index 8adf5244c0..9d7f2ca910 100644 --- a/cli/exec/metadata.go +++ b/cli/exec/metadata.go @@ -45,7 +45,7 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata { Name: repoName, Owner: repoOwner, RemoteID: c.String("repo-remote-id"), - URL: c.String("repo-url"), + ForgeURL: c.String("repo-url"), CloneURL: c.String("repo-clone-url"), CloneSSHURL: c.String("repo-clone-ssh-url"), Private: c.Bool("repo-private"), @@ -59,7 +59,7 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata { Finished: c.Int64("pipeline-finished"), Status: c.String("pipeline-status"), Event: c.String("pipeline-event"), - URL: c.String("pipeline-url"), + ForgeURL: c.String("pipeline-url"), Target: c.String("pipeline-target"), Commit: metadata.Commit{ Sha: c.String("commit-sha"), @@ -81,7 +81,7 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata { Finished: c.Int64("prev-pipeline-finished"), Status: c.String("prev-pipeline-status"), Event: c.String("prev-pipeline-event"), - URL: c.String("prev-pipeline-url"), + ForgeURL: c.String("prev-pipeline-url"), Commit: metadata.Commit{ Sha: c.String("prev-commit-sha"), Ref: c.String("prev-commit-ref"), diff --git a/cli/repo/repo_info.go b/cli/repo/repo_info.go index 148fc1035b..f3c0fc73e5 100644 --- a/cli/repo/repo_info.go +++ b/cli/repo/repo_info.go @@ -60,7 +60,7 @@ func repoInfo(c *cli.Context) error { // template for repo information var tmplRepoInfo = `Owner: {{ .Owner }} Repo: {{ .Name }} -URL: {{ .URL }} +URL: {{ .ForgeURL }} Config path: {{ .Config }} Visibility: {{ .Visibility }} Private: {{ .IsSCMPrivate }} diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index ac85e68927..fac05e6947 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -59,7 +59,7 @@ func MetadataFromStruct(forge metadata.ServerForge, repo *model.Repo, pipeline, Name: repo.Name, Owner: repo.Owner, RemoteID: fmt.Sprint(repo.ForgeRemoteID), - URL: repo.URL, + ForgeURL: repo.ForgeURL, CloneURL: repo.Clone, CloneSSHURL: repo.CloneSSH, Private: repo.IsSCMPrivate, @@ -126,7 +126,7 @@ func metadataPipelineFromModelPipeline(pipeline *model.Pipeline, includeParent b Finished: pipeline.Finished, Status: string(pipeline.Status), Event: string(pipeline.Event), - URL: pipeline.URL, + ForgeURL: pipeline.ForgeURL, Target: pipeline.Deploy, Commit: metadata.Commit{ Sha: pipeline.Commit, diff --git a/pipeline/frontend/metadata/environment.go b/pipeline/frontend/metadata/environment.go index 0d00a8cdcf..5bba484b0a 100644 --- a/pipeline/frontend/metadata/environment.go +++ b/pipeline/frontend/metadata/environment.go @@ -44,7 +44,7 @@ func (m *Metadata) Environ() map[string]string { "CI_REPO_OWNER": m.Repo.Owner, "CI_REPO_REMOTE_ID": m.Repo.RemoteID, "CI_REPO_SCM": "git", - "CI_REPO_URL": m.Repo.URL, + "CI_REPO_URL": m.Repo.ForgeURL, "CI_REPO_CLONE_URL": m.Repo.CloneURL, "CI_REPO_CLONE_SSH_URL": m.Repo.CloneSSHURL, "CI_REPO_DEFAULT_BRANCH": m.Repo.Branch, @@ -57,7 +57,7 @@ func (m *Metadata) Environ() map[string]string { "CI_COMMIT_BRANCH": m.Curr.Commit.Branch, "CI_COMMIT_SOURCE_BRANCH": sourceBranch, "CI_COMMIT_TARGET_BRANCH": targetBranch, - "CI_COMMIT_URL": m.Curr.URL, + "CI_COMMIT_URL": m.Curr.ForgeURL, "CI_COMMIT_MESSAGE": m.Curr.Commit.Message, "CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, "CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, @@ -70,7 +70,7 @@ func (m *Metadata) Environ() map[string]string { "CI_PIPELINE_PARENT": strconv.FormatInt(m.Curr.Parent, 10), "CI_PIPELINE_EVENT": m.Curr.Event, "CI_PIPELINE_URL": m.getPipelineStatusURL(m.Curr, 0), - "CI_PIPELINE_FORGE_URL": m.Curr.URL, + "CI_PIPELINE_FORGE_URL": m.Curr.ForgeURL, "CI_PIPELINE_DEPLOY_TARGET": m.Curr.Target, "CI_PIPELINE_STATUS": m.Curr.Status, "CI_PIPELINE_CREATED": strconv.FormatInt(m.Curr.Created, 10), @@ -91,7 +91,7 @@ func (m *Metadata) Environ() map[string]string { "CI_PREV_COMMIT_REF": m.Prev.Commit.Ref, "CI_PREV_COMMIT_REFSPEC": m.Prev.Commit.Refspec, "CI_PREV_COMMIT_BRANCH": m.Prev.Commit.Branch, - "CI_PREV_COMMIT_URL": m.Prev.URL, + "CI_PREV_COMMIT_URL": m.Prev.ForgeURL, "CI_PREV_COMMIT_MESSAGE": m.Prev.Commit.Message, "CI_PREV_COMMIT_AUTHOR": m.Prev.Commit.Author.Name, "CI_PREV_COMMIT_AUTHOR_EMAIL": m.Prev.Commit.Author.Email, @@ -101,7 +101,7 @@ func (m *Metadata) Environ() map[string]string { "CI_PREV_PIPELINE_PARENT": strconv.FormatInt(m.Prev.Parent, 10), "CI_PREV_PIPELINE_EVENT": m.Prev.Event, "CI_PREV_PIPELINE_URL": m.getPipelineStatusURL(m.Prev, 0), - "CI_PREV_PIPELINE_FORGE_URL": m.Curr.URL, + "CI_PREV_PIPELINE_FORGE_URL": m.Curr.ForgeURL, "CI_PREV_PIPELINE_DEPLOY_TARGET": m.Prev.Target, "CI_PREV_PIPELINE_STATUS": m.Prev.Status, "CI_PREV_PIPELINE_CREATED": strconv.FormatInt(m.Prev.Created, 10), diff --git a/pipeline/frontend/metadata/types.go b/pipeline/frontend/metadata/types.go index 4f54c0fdbb..002e815a9d 100644 --- a/pipeline/frontend/metadata/types.go +++ b/pipeline/frontend/metadata/types.go @@ -33,7 +33,7 @@ type ( Name string Owner string RemoteID string - URL string + ForgeURL string CloneURL string CloneSSHURL string Private bool @@ -51,7 +51,7 @@ type ( Timeout int64 Status string Event string - URL string + ForgeURL string Target string Trusted bool Commit Commit diff --git a/pipeline/frontend/metadata_test.go b/pipeline/frontend/metadata_test.go index 0ed610d305..1501605144 100644 --- a/pipeline/frontend/metadata_test.go +++ b/pipeline/frontend/metadata_test.go @@ -62,7 +62,7 @@ func TestMetadataFromStruct(t *testing.T) { repo *model.Repo pipeline, last *model.Pipeline workflow *model.Workflow - sysURL string + sysURL string expectedMetadata metadata.Metadata expectedEnviron map[string]string }{ @@ -88,15 +88,15 @@ func TestMetadataFromStruct(t *testing.T) { { name: "Test with forge", forge: forge, - repo: &model.Repo{FullName: "testUser/testRepo", URL: "https://gitea.com/testUser/testRepo", Clone: "https://gitea.com/testUser/testRepo.git", CloneSSH: "git@gitea.com:testUser/testRepo.git", Branch: "main", IsSCMPrivate: true}, + repo: &model.Repo{FullName: "testUser/testRepo", ForgeURL: "https://gitea.com/testUser/testRepo", Clone: "https://gitea.com/testUser/testRepo.git", CloneSSH: "git@gitea.com:testUser/testRepo.git", Branch: "main", IsSCMPrivate: true}, pipeline: &model.Pipeline{Number: 3}, last: &model.Pipeline{Number: 2}, workflow: &model.Workflow{Name: "hello"}, - sysURL: "https://example.com", + sysURL: "https://example.com", expectedMetadata: metadata.Metadata{ Forge: metadata.Forge{Type: "gitea", URL: "https://gitea.com"}, Sys: metadata.System{Name: "woodpecker", Host: "example.com", URL: "https://example.com"}, - Repo: metadata.Repo{Owner: "testUser", Name: "testRepo", URL: "https://gitea.com/testUser/testRepo", CloneURL: "https://gitea.com/testUser/testRepo.git", CloneSSHURL: "git@gitea.com:testUser/testRepo.git", Branch: "main", Private: true}, + Repo: metadata.Repo{Owner: "testUser", Name: "testRepo", ForgeURL: "https://gitea.com/testUser/testRepo", CloneURL: "https://gitea.com/testUser/testRepo.git", CloneSSHURL: "git@gitea.com:testUser/testRepo.git", Branch: "main", Private: true}, Curr: metadata.Pipeline{Number: 3}, Prev: metadata.Pipeline{Number: 2}, Workflow: metadata.Workflow{Name: "hello"}, diff --git a/pipeline/frontend/yaml/compiler/compiler_test.go b/pipeline/frontend/yaml/compiler/compiler_test.go index 9dcfa34ec2..9734082ed2 100644 --- a/pipeline/frontend/yaml/compiler/compiler_test.go +++ b/pipeline/frontend/yaml/compiler/compiler_test.go @@ -60,7 +60,7 @@ func TestCompilerCompile(t *testing.T) { Owner: "octacat", Name: "hello-world", Private: true, - URL: "https://github.com/octocat/hello-world", + ForgeURL: "https://github.com/octocat/hello-world", CloneURL: "https://github.com/octocat/hello-world.git", }, }), diff --git a/pipeline/frontend/yaml/compiler/option_test.go b/pipeline/frontend/yaml/compiler/option_test.go index e788a971ed..a3ca233ae2 100644 --- a/pipeline/frontend/yaml/compiler/option_test.go +++ b/pipeline/frontend/yaml/compiler/option_test.go @@ -115,7 +115,7 @@ func TestWithMetadata(t *testing.T) { Owner: "octacat", Name: "hello-world", Private: true, - URL: "https://github.com/octocat/hello-world", + ForgeURL: "https://github.com/octocat/hello-world", CloneURL: "https://github.com/octocat/hello-world.git", }, } @@ -129,7 +129,7 @@ func TestWithMetadata(t *testing.T) { if compiler.env["CI_REPO_NAME"] != metadata.Repo.Name { t.Errorf("WithMetadata must set CI_REPO_NAME") } - if compiler.env["CI_REPO_URL"] != metadata.Repo.URL { + if compiler.env["CI_REPO_URL"] != metadata.Repo.ForgeURL { t.Errorf("WithMetadata must set CI_REPO_URL") } if compiler.env["CI_REPO_CLONE_URL"] != metadata.Repo.CloneURL { diff --git a/pipeline/stepBuilder.go b/pipeline/stepBuilder.go index 494738ad14..05b28cc212 100644 --- a/pipeline/stepBuilder.go +++ b/pipeline/stepBuilder.go @@ -291,7 +291,7 @@ func (b *StepBuilder) toInternalRepresentation(parsed *yaml_types.Workflow, envi ), ), compiler.WithProxy(b.ProxyOpts), - compiler.WithWorkspaceFromURL("/woodpecker", b.Repo.URL), + compiler.WithWorkspaceFromURL("/woodpecker", b.Repo.ForgeURL), compiler.WithMetadata(metadata), compiler.WithTrusted(b.Repo.IsTrusted), compiler.WithNetrcOnlyTrusted(b.Repo.NetrcOnlyTrusted), diff --git a/server/api/pipeline.go b/server/api/pipeline.go index 90ad09cb93..8c4897d506 100644 --- a/server/api/pipeline.go +++ b/server/api/pipeline.go @@ -88,7 +88,7 @@ func createTmpPipeline(event model.WebhookEvent, commitSHA string, repo *model.R Email: user.Email, // TODO: Generate proper URL to commit - URL: repo.URL, + ForgeURL: repo.ForgeURL, } } diff --git a/server/cron/cron.go b/server/cron/cron.go index 53c674b578..5e8e8a4981 100644 --- a/server/cron/cron.go +++ b/server/cron/cron.go @@ -139,6 +139,6 @@ func CreatePipeline(ctx context.Context, store store.Store, f forge.Forge, cron Message: cron.Name, Timestamp: cron.NextExec, Sender: cron.Name, - URL: repo.URL, + ForgeURL: repo.ForgeURL, }, nil } diff --git a/server/forge/bitbucket/convert.go b/server/forge/bitbucket/convert.go index 9a6953e4f7..b6cd42a833 100644 --- a/server/forge/bitbucket/convert.go +++ b/server/forge/bitbucket/convert.go @@ -56,7 +56,7 @@ func convertRepo(from *internal.Repo, perm *internal.RepoPerm) *model.Repo { Owner: strings.Split(from.FullName, "/")[0], Name: strings.Split(from.FullName, "/")[1], FullName: from.FullName, - URL: from.Links.HTML.Href, + ForgeURL: from.Links.HTML.Href, IsSCMPrivate: from.IsPrivate, Avatar: from.Owner.Links.Avatar.Href, SCMKind: model.SCMKind(from.Scm), @@ -171,7 +171,7 @@ func convertPullHook(from *internal.PullRequestHook) *model.Pipeline { from.PullRequest.Dest.Branch.Name, ), CloneURL: fmt.Sprintf("https://bitbucket.org/%s", from.PullRequest.Source.Repo.FullName), - URL: from.PullRequest.Links.HTML.Href, + ForgeURL: from.PullRequest.Links.HTML.Href, Branch: from.PullRequest.Dest.Branch.Name, Message: from.PullRequest.Desc, Avatar: from.Actor.Links.Avatar.Href, @@ -186,7 +186,7 @@ func convertPullHook(from *internal.PullRequestHook) *model.Pipeline { func convertPushHook(hook *internal.PushHook, change *internal.Change) *model.Pipeline { pipeline := &model.Pipeline{ Commit: change.New.Target.Hash, - URL: change.New.Target.Links.HTML.Href, + ForgeURL: change.New.Target.Links.HTML.Href, Branch: change.New.Name, Message: change.New.Target.Message, Avatar: hook.Actor.Links.Avatar.Href, diff --git a/server/forge/bitbucket/convert_test.go b/server/forge/bitbucket/convert_test.go index 08485a4146..5ab3f7cf14 100644 --- a/server/forge/bitbucket/convert_test.go +++ b/server/forge/bitbucket/convert_test.go @@ -65,7 +65,7 @@ func Test_helper(t *testing.T) { g.Assert(string(to.SCMKind)).Equal(from.Scm) g.Assert(to.IsSCMPrivate).Equal(from.IsPrivate) g.Assert(to.Clone).Equal(from.Links.HTML.Href) - g.Assert(to.URL).Equal(from.Links.HTML.Href) + g.Assert(to.ForgeURL).Equal(from.Links.HTML.Href) g.Assert(to.Perm.Push).IsTrue() g.Assert(to.Perm.Admin).IsFalse() }) @@ -139,7 +139,7 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Avatar).Equal(hook.Actor.Links.Avatar.Href) g.Assert(pipeline.Commit).Equal(hook.PullRequest.Dest.Commit.Hash) g.Assert(pipeline.Branch).Equal(hook.PullRequest.Dest.Branch.Name) - g.Assert(pipeline.URL).Equal(hook.PullRequest.Links.HTML.Href) + g.Assert(pipeline.ForgeURL).Equal(hook.PullRequest.Links.HTML.Href) g.Assert(pipeline.Ref).Equal("refs/heads/main") g.Assert(pipeline.Refspec).Equal("change:main") g.Assert(pipeline.CloneURL).Equal("https://bitbucket.org/baz/bar") @@ -167,7 +167,7 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Avatar).Equal(hook.Actor.Links.Avatar.Href) g.Assert(pipeline.Commit).Equal(change.New.Target.Hash) g.Assert(pipeline.Branch).Equal(change.New.Name) - g.Assert(pipeline.URL).Equal(change.New.Target.Links.HTML.Href) + g.Assert(pipeline.ForgeURL).Equal(change.New.Target.Links.HTML.Href) g.Assert(pipeline.Ref).Equal("refs/heads/main") g.Assert(pipeline.Message).Equal(change.New.Target.Message) g.Assert(pipeline.Timestamp).Equal(change.New.Target.Date.Unix()) diff --git a/server/forge/gitea/gitea_test.go b/server/forge/gitea/gitea_test.go index 93211fb0bd..d28e8ad7f2 100644 --- a/server/forge/gitea/gitea_test.go +++ b/server/forge/gitea/gitea_test.go @@ -92,7 +92,7 @@ func Test_gitea(t *testing.T) { g.Assert(repo.FullName).Equal(fakeRepo.Owner + "/" + fakeRepo.Name) g.Assert(repo.IsSCMPrivate).IsTrue() g.Assert(repo.Clone).Equal("http://localhost/test_name/repo_name.git") - g.Assert(repo.URL).Equal("http://localhost/test_name/repo_name") + g.Assert(repo.ForgeURL).Equal("http://localhost/test_name/repo_name") }) g.It("Should handle a not found error", func() { _, err := c.Repo(ctx, fakeUser, "0", fakeRepoNotFound.Owner, fakeRepoNotFound.Name) diff --git a/server/forge/gitea/helper.go b/server/forge/gitea/helper.go index be9885ad3b..843213b633 100644 --- a/server/forge/gitea/helper.go +++ b/server/forge/gitea/helper.go @@ -43,7 +43,7 @@ func toRepo(from *gitea.Repository) *model.Repo { Owner: from.Owner.UserName, FullName: from.FullName, Avatar: avatar, - URL: from.HTMLURL, + ForgeURL: from.HTMLURL, IsSCMPrivate: from.Private || from.Owner.Visibility != gitea.VisibleTypePublic, Clone: from.CloneURL, CloneSSH: from.SSHURL, @@ -92,7 +92,7 @@ func pipelineFromPush(hook *pushHook) *model.Pipeline { Event: model.EventPush, Commit: hook.After, Ref: hook.Ref, - URL: link, + ForgeURL: link, Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"), Message: message, Avatar: avatar, @@ -131,7 +131,7 @@ func pipelineFromTag(hook *pushHook) *model.Pipeline { Event: model.EventTag, Commit: hook.Sha, Ref: fmt.Sprintf("refs/tags/%s", hook.Ref), - URL: fmt.Sprintf("%s/src/tag/%s", hook.Repo.HTMLURL, hook.Ref), + ForgeURL: fmt.Sprintf("%s/src/tag/%s", hook.Repo.HTMLURL, hook.Ref), Branch: fmt.Sprintf("refs/tags/%s", hook.Ref), Message: fmt.Sprintf("created tag %s", hook.Ref), Avatar: avatar, @@ -148,16 +148,16 @@ func pipelineFromPullRequest(hook *pullRequestHook) *model.Pipeline { fixMalformedAvatar(hook.PullRequest.Poster.AvatarURL), ) pipeline := &model.Pipeline{ - Event: model.EventPull, - Commit: hook.PullRequest.Head.Sha, - URL: hook.PullRequest.URL, - Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number), - Branch: hook.PullRequest.Base.Ref, - Message: hook.PullRequest.Title, - Author: hook.PullRequest.Poster.UserName, - Avatar: avatar, - Sender: hook.Sender.UserName, - Title: hook.PullRequest.Title, + Event: model.EventPull, + Commit: hook.PullRequest.Head.Sha, + ForgeURL: hook.PullRequest.URL, + Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number), + Branch: hook.PullRequest.Base.Ref, + Message: hook.PullRequest.Title, + Author: hook.PullRequest.Poster.UserName, + Avatar: avatar, + Sender: hook.Sender.UserName, + Title: hook.PullRequest.Title, Refspec: fmt.Sprintf("%s:%s", hook.PullRequest.Head.Ref, hook.PullRequest.Base.Ref, diff --git a/server/forge/gitea/helper_test.go b/server/forge/gitea/helper_test.go index 05584c5dd0..8041dd9889 100644 --- a/server/forge/gitea/helper_test.go +++ b/server/forge/gitea/helper_test.go @@ -99,7 +99,7 @@ func Test_parse(t *testing.T) { g.Assert(pipeline.Event).Equal(model.EventPush) g.Assert(pipeline.Commit).Equal(hook.After) g.Assert(pipeline.Ref).Equal(hook.Ref) - g.Assert(pipeline.URL).Equal(hook.Commits[0].URL) + g.Assert(pipeline.ForgeURL).Equal(hook.Commits[0].URL) g.Assert(pipeline.Branch).Equal("main") g.Assert(pipeline.Message).Equal(hook.Commits[0].Message) g.Assert(pipeline.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87") @@ -114,7 +114,7 @@ func Test_parse(t *testing.T) { g.Assert(repo.Name).Equal(hook.Repo.Name) g.Assert(repo.Owner).Equal(hook.Repo.Owner.UserName) g.Assert(repo.FullName).Equal("gordon/hello-world") - g.Assert(repo.URL).Equal(hook.Repo.HTMLURL) + g.Assert(repo.ForgeURL).Equal(hook.Repo.HTMLURL) }) g.It("Should return a Pipeline struct from a tag hook", func() { @@ -125,7 +125,7 @@ func Test_parse(t *testing.T) { g.Assert(pipeline.Commit).Equal(hook.Sha) g.Assert(pipeline.Ref).Equal("refs/tags/v1.0.0") g.Assert(pipeline.Branch).Equal("refs/tags/v1.0.0") - g.Assert(pipeline.URL).Equal("http://gitea.golang.org/gordon/hello-world/src/tag/v1.0.0") + g.Assert(pipeline.ForgeURL).Equal("http://gitea.golang.org/gordon/hello-world/src/tag/v1.0.0") g.Assert(pipeline.Message).Equal("created tag v1.0.0") }) @@ -136,7 +136,7 @@ func Test_parse(t *testing.T) { g.Assert(pipeline.Event).Equal(model.EventPull) g.Assert(pipeline.Commit).Equal(hook.PullRequest.Head.Sha) g.Assert(pipeline.Ref).Equal("refs/pull/1/head") - g.Assert(pipeline.URL).Equal(hook.PullRequest.URL) + g.Assert(pipeline.ForgeURL).Equal(hook.PullRequest.URL) g.Assert(pipeline.Branch).Equal("main") g.Assert(pipeline.Refspec).Equal("feature/changes:main") g.Assert(pipeline.Message).Equal(hook.PullRequest.Title) @@ -151,7 +151,7 @@ func Test_parse(t *testing.T) { g.Assert(repo.Name).Equal(hook.Repo.Name) g.Assert(repo.Owner).Equal(hook.Repo.Owner.UserName) g.Assert(repo.FullName).Equal("gordon/hello-world") - g.Assert(repo.URL).Equal(hook.Repo.HTMLURL) + g.Assert(repo.ForgeURL).Equal(hook.Repo.HTMLURL) }) g.It("Should return a Perm struct from a Gitea Perm", func() { @@ -209,7 +209,7 @@ func Test_parse(t *testing.T) { g.Assert(repo.Owner).Equal(from.Owner.UserName) g.Assert(repo.Name).Equal("hello-world") g.Assert(repo.Branch).Equal("main") - g.Assert(repo.URL).Equal(from.HTMLURL) + g.Assert(repo.ForgeURL).Equal(from.HTMLURL) g.Assert(repo.Clone).Equal(from.CloneURL) g.Assert(repo.Avatar).Equal(from.Owner.AvatarURL) g.Assert(repo.IsSCMPrivate).Equal(from.Private) diff --git a/server/forge/github/convert.go b/server/forge/github/convert.go index 9660674d4b..f802bc759e 100644 --- a/server/forge/github/convert.go +++ b/server/forge/github/convert.go @@ -86,7 +86,7 @@ func convertRepo(from *github.Repository) *model.Repo { ForgeRemoteID: model.ForgeRemoteID(fmt.Sprint(from.GetID())), Name: from.GetName(), FullName: from.GetFullName(), - URL: from.GetHTMLURL(), + ForgeURL: from.GetHTMLURL(), IsSCMPrivate: from.GetPrivate(), Clone: from.GetCloneURL(), CloneSSH: from.GetSSHURL(), @@ -146,7 +146,7 @@ func convertRepoHook(eventRepo *github.PushEventRepository) *model.Repo { Owner: eventRepo.GetOwner().GetLogin(), Name: eventRepo.GetName(), FullName: eventRepo.GetFullName(), - URL: eventRepo.GetHTMLURL(), + ForgeURL: eventRepo.GetHTMLURL(), IsSCMPrivate: eventRepo.GetPrivate(), Clone: eventRepo.GetCloneURL(), CloneSSH: eventRepo.GetSSHURL(), diff --git a/server/forge/github/convert_test.go b/server/forge/github/convert_test.go index 12448783b0..3f71bc5f58 100644 --- a/server/forge/github/convert_test.go +++ b/server/forge/github/convert_test.go @@ -118,7 +118,7 @@ func Test_helper(t *testing.T) { g.Assert(string(to.SCMKind)).Equal("git") g.Assert(to.IsSCMPrivate).IsTrue() g.Assert(to.Clone).Equal("https://github.com/octocat/hello-world.git") - g.Assert(to.URL).Equal("https://github.com/octocat/hello-world") + g.Assert(to.ForgeURL).Equal("https://github.com/octocat/hello-world") }) g.It("should convert repository permissions", func() { @@ -174,7 +174,7 @@ func Test_helper(t *testing.T) { g.Assert(repo.Name).Equal(*from.Name) g.Assert(repo.FullName).Equal(*from.FullName) g.Assert(repo.IsSCMPrivate).Equal(*from.Private) - g.Assert(repo.URL).Equal(*from.HTMLURL) + g.Assert(repo.ForgeURL).Equal(*from.HTMLURL) g.Assert(repo.Clone).Equal(*from.CloneURL) g.Assert(repo.Branch).Equal(*from.DefaultBranch) }) @@ -239,7 +239,7 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Ref).Equal("refs/heads/main") g.Assert(pipeline.Commit).Equal(*from.Deployment.SHA) g.Assert(pipeline.Message).Equal(*from.Deployment.Description) - g.Assert(pipeline.URL).Equal(*from.Deployment.URL) + g.Assert(pipeline.ForgeURL).Equal(*from.Deployment.URL) g.Assert(pipeline.Author).Equal(*from.Sender.Login) g.Assert(pipeline.Avatar).Equal(*from.Sender.AvatarURL) }) @@ -262,7 +262,7 @@ func Test_helper(t *testing.T) { g.Assert(pipeline.Ref).Equal("refs/heads/main") g.Assert(pipeline.Commit).Equal(*from.HeadCommit.ID) g.Assert(pipeline.Message).Equal(*from.HeadCommit.Message) - g.Assert(pipeline.URL).Equal(*from.HeadCommit.URL) + g.Assert(pipeline.ForgeURL).Equal(*from.HeadCommit.URL) g.Assert(pipeline.Author).Equal(*from.Sender.Login) g.Assert(pipeline.Avatar).Equal(*from.Sender.AvatarURL) g.Assert(pipeline.Email).Equal(*from.HeadCommit.Author.Email) diff --git a/server/forge/github/github.go b/server/forge/github/github.go index a88a851cbf..917b1e289c 100644 --- a/server/forge/github/github.go +++ b/server/forge/github/github.go @@ -488,7 +488,7 @@ func (c *client) Status(ctx context.Context, user *model.User, repo *model.Repo, client := c.newClientToken(ctx, user.Token) if pipeline.Event == model.EventDeploy { - matches := reDeploy.FindStringSubmatch(pipeline.URL) + matches := reDeploy.FindStringSubmatch(pipeline.ForgeURL) if len(matches) != 2 { return nil } diff --git a/server/forge/github/github_test.go b/server/forge/github/github_test.go index 9150d8e75a..48c775d5a3 100644 --- a/server/forge/github/github_test.go +++ b/server/forge/github/github_test.go @@ -86,7 +86,7 @@ func Test_github(t *testing.T) { g.Assert(repo.FullName).Equal(fakeRepo.FullName) g.Assert(repo.IsSCMPrivate).IsTrue() g.Assert(repo.Clone).Equal(fakeRepo.Clone) - g.Assert(repo.URL).Equal(fakeRepo.URL) + g.Assert(repo.ForgeURL).Equal(fakeRepo.ForgeURL) }) g.It("Should handle a not found error", func() { _, err := c.Repo(ctx, fakeUser, "0", fakeRepoNotFound.Owner, fakeRepoNotFound.Name) @@ -124,7 +124,7 @@ var ( Name: "Hello-World", FullName: "octocat/Hello-World", Avatar: "https://github.com/images/error/octocat_happy.gif", - URL: "https://github.com/octocat/Hello-World", + ForgeURL: "https://github.com/octocat/Hello-World", Clone: "https://github.com/octocat/Hello-World.git", IsSCMPrivate: true, } diff --git a/server/forge/github/parse.go b/server/forge/github/parse.go index 0209d90b42..a9e35df67f 100644 --- a/server/forge/github/parse.go +++ b/server/forge/github/parse.go @@ -82,7 +82,7 @@ func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline, error) Event: model.EventPush, Commit: hook.GetHeadCommit().GetID(), Ref: hook.GetRef(), - URL: hook.GetHeadCommit().GetURL(), + ForgeURL: hook.GetHeadCommit().GetURL(), Branch: strings.Replace(hook.GetRef(), "refs/heads/", "", -1), Message: hook.GetHeadCommit().GetMessage(), Email: hook.GetHeadCommit().GetAuthor().GetEmail(), @@ -115,16 +115,16 @@ func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline, error) // If the commit type is unsupported nil values are returned. func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline, error) { pipeline := &model.Pipeline{ - Event: model.EventDeploy, - Commit: hook.GetDeployment().GetSHA(), - URL: hook.GetDeployment().GetURL(), - Message: hook.GetDeployment().GetDescription(), - Ref: hook.GetDeployment().GetRef(), - Branch: hook.GetDeployment().GetRef(), - Deploy: hook.GetDeployment().GetEnvironment(), - Avatar: hook.GetSender().GetAvatarURL(), - Author: hook.GetSender().GetLogin(), - Sender: hook.GetSender().GetLogin(), + Event: model.EventDeploy, + Commit: hook.GetDeployment().GetSHA(), + ForgeURL: hook.GetDeployment().GetURL(), + Message: hook.GetDeployment().GetDescription(), + Ref: hook.GetDeployment().GetRef(), + Branch: hook.GetDeployment().GetRef(), + Deploy: hook.GetDeployment().GetEnvironment(), + Avatar: hook.GetSender().GetAvatarURL(), + Author: hook.GetSender().GetLogin(), + Sender: hook.GetSender().GetLogin(), } // if the ref is a sha or short sha we need to manually construct the ref. if strings.HasPrefix(pipeline.Commit, pipeline.Ref) || pipeline.Commit == pipeline.Ref { @@ -153,7 +153,7 @@ func parsePullHook(hook *github.PullRequestEvent, merge bool) (*github.PullReque pipeline := &model.Pipeline{ Event: model.EventPull, Commit: hook.GetPullRequest().GetHead().GetSHA(), - URL: hook.GetPullRequest().GetHTMLURL(), + ForgeURL: hook.GetPullRequest().GetHTMLURL(), Ref: fmt.Sprintf(headRefs, hook.GetPullRequest().GetNumber()), Branch: hook.GetPullRequest().GetBase().GetRef(), Message: hook.GetPullRequest().GetTitle(), diff --git a/server/forge/gitlab/convert.go b/server/forge/gitlab/convert.go index 73658126d2..d4f8acddc5 100644 --- a/server/forge/gitlab/convert.go +++ b/server/forge/gitlab/convert.go @@ -41,7 +41,7 @@ func (g *GitLab) convertGitLabRepo(_repo *gitlab.Project) (*model.Repo, error) { Name: name, FullName: _repo.PathWithNamespace, Avatar: _repo.AvatarURL, - URL: _repo.WebURL, + ForgeURL: _repo.WebURL, Clone: _repo.HTTPURLToRepo, CloneSSH: _repo.SSHURLToRepo, Branch: _repo.DefaultBranch, @@ -90,7 +90,7 @@ func convertMergeRequestHook(hook *gitlab.MergeEvent, req *http.Request) (int, * } repo.ForgeRemoteID = model.ForgeRemoteID(fmt.Sprint(obj.TargetProjectID)) - repo.URL = target.WebURL + repo.ForgeURL = target.WebURL if target.GitHTTPURL != "" { repo.Clone = target.GitHTTPURL @@ -130,7 +130,7 @@ func convertMergeRequestHook(hook *gitlab.MergeEvent, req *http.Request) (int, * } pipeline.Title = obj.Title - pipeline.URL = obj.URL + pipeline.ForgeURL = obj.URL pipeline.PullRequestLabels = convertLabels(hook.Labels) return obj.IID, repo, pipeline, nil @@ -147,7 +147,7 @@ func convertPushHook(hook *gitlab.PushEvent) (*model.Repo, *model.Pipeline, erro repo.ForgeRemoteID = model.ForgeRemoteID(fmt.Sprint(hook.ProjectID)) repo.Avatar = hook.Project.AvatarURL - repo.URL = hook.Project.WebURL + repo.ForgeURL = hook.Project.WebURL repo.Clone = hook.Project.GitHTTPURL repo.CloneSSH = hook.Project.GitSSHURL repo.FullName = hook.Project.PathWithNamespace @@ -200,7 +200,7 @@ func convertTagHook(hook *gitlab.TagEvent) (*model.Repo, *model.Pipeline, error) repo.ForgeRemoteID = model.ForgeRemoteID(fmt.Sprint(hook.ProjectID)) repo.Avatar = hook.Project.AvatarURL - repo.URL = hook.Project.WebURL + repo.ForgeURL = hook.Project.WebURL repo.Clone = hook.Project.GitHTTPURL repo.CloneSSH = hook.Project.GitSSHURL repo.FullName = hook.Project.PathWithNamespace diff --git a/server/model/pipeline.go b/server/model/pipeline.go index 698a78b15f..10c95bdea9 100644 --- a/server/model/pipeline.go +++ b/server/model/pipeline.go @@ -46,7 +46,7 @@ type Pipeline struct { Sender string `json:"sender" xorm:"pipeline_sender"` // uses reported user for webhooks and name of cron for cron pipelines Avatar string `json:"author_avatar" xorm:"pipeline_avatar"` Email string `json:"author_email" xorm:"pipeline_email"` - URL string `json:"url" xorm:"pipeline_url"` + ForgeURL string `json:"forge_url" xorm:"pipeline_forge_url"` Reviewer string `json:"reviewed_by" xorm:"pipeline_reviewer"` Reviewed int64 `json:"reviewed_at" xorm:"pipeline_reviewed"` Workflows []*Workflow `json:"workflows,omitempty" xorm:"-"` diff --git a/server/model/repo.go b/server/model/repo.go index 6780ae3a3e..d4baa43889 100644 --- a/server/model/repo.go +++ b/server/model/repo.go @@ -31,7 +31,7 @@ type Repo struct { Name string `json:"name" xorm:"UNIQUE(name) 'repo_name'"` FullName string `json:"full_name" xorm:"UNIQUE 'repo_full_name'"` Avatar string `json:"avatar_url,omitempty" xorm:"varchar(500) 'repo_avatar'"` - URL string `json:"url,omitempty" xorm:"varchar(1000) 'repo_url'"` + ForgeURL string `json:"forge_url,omitempty" xorm:"varchar(1000) 'repo_forge_url'"` Clone string `json:"clone_url,omitempty" xorm:"varchar(1000) 'repo_clone'"` CloneSSH string `json:"clone_url_ssh" xorm:"varchar(1000) 'repo_clone_ssh'"` Branch string `json:"default_branch,omitempty" xorm:"varchar(500) 'repo_branch'"` @@ -83,7 +83,7 @@ func (r *Repo) Update(from *Repo) { r.Name = from.Name r.FullName = from.FullName r.Avatar = from.Avatar - r.URL = from.URL + r.ForgeURL = from.ForgeURL r.SCMKind = from.SCMKind if len(from.Clone) > 0 { r.Clone = from.Clone diff --git a/server/store/datastore/migration/027_link_to_url.go b/server/store/datastore/migration/027_link_to_url.go index 7f9328383b..51b3deb057 100644 --- a/server/store/datastore/migration/027_link_to_url.go +++ b/server/store/datastore/migration/027_link_to_url.go @@ -22,10 +22,10 @@ var renameLinkToURL = task{ name: "rename-link-to-url", required: true, fn: func(sess *xorm.Session) (err error) { - if err := renameColumn(sess, "pipelines", "pipeline_link", "pipeline_url"); err != nil { + if err := renameColumn(sess, "pipelines", "pipeline_link", "pipeline_forge_url"); err != nil { return err } - return renameColumn(sess, "repos", "repo_link", "repo_url") + return renameColumn(sess, "repos", "repo_link", "repo_forge_url") }, } diff --git a/server/store/datastore/migration/migration.go b/server/store/datastore/migration/migration.go index 737c4a0a2b..7cbe817f2c 100644 --- a/server/store/datastore/migration/migration.go +++ b/server/store/datastore/migration/migration.go @@ -59,6 +59,7 @@ var migrationTasks = []*task{ &alterTableConfigUpdateColumnConfigDataType, &removePluginOnlyOptionFromSecretsTable, &convertToNewPipelineErrorFormat, + &renameLinkToURL, } var allBeans = []interface{}{ diff --git a/web/src/components/repo/pipeline/PipelineStepList.vue b/web/src/components/repo/pipeline/PipelineStepList.vue index 11e5e363da..43cb409da7 100644 --- a/web/src/components/repo/pipeline/PipelineStepList.vue +++ b/web/src/components/repo/pipeline/PipelineStepList.vue @@ -13,7 +13,7 @@ {{ prettyRef }} @@ -41,7 +41,7 @@ diff --git a/web/src/lib/api/types/pipeline.ts b/web/src/lib/api/types/pipeline.ts index bf081f0f25..82235f8a74 100644 --- a/web/src/lib/api/types/pipeline.ts +++ b/web/src/lib/api/types/pipeline.ts @@ -77,7 +77,7 @@ export type Pipeline = { author_email: string; // This url will point to the repository state associated with the pipeline's commit. - url: string; + forge_url: string; signed: boolean; diff --git a/web/src/lib/api/types/repo.ts b/web/src/lib/api/types/repo.ts index e9ca70b193..ed6821cde4 100644 --- a/web/src/lib/api/types/repo.ts +++ b/web/src/lib/api/types/repo.ts @@ -30,7 +30,7 @@ export type Repo = { avatar_url: string; // The url to view the repository. - url: string; + forge_url: string; // The url used to clone the repository. clone_url: string; diff --git a/web/src/views/repo/RepoWrapper.vue b/web/src/views/repo/RepoWrapper.vue index 9ee57f4ad2..a297092ae9 100644 --- a/web/src/views/repo/RepoWrapper.vue +++ b/web/src/views/repo/RepoWrapper.vue @@ -17,7 +17,7 @@ - +