Rename link to url (#2812)

As of https://woodpecker-ci.org/docs/next/usage/terminiology#conventions
This commit is contained in:
qwerty287 2023-11-14 17:12:12 +01:00 committed by GitHub
parent 451b71dcd4
commit 342b25826c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 198 additions and 146 deletions

View file

@ -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"},

View file

@ -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"),
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"),
Link: c.String("pipeline-link"),
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"),
Link: c.String("prev-pipeline-link"),
ForgeURL: 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,
},

View file

@ -60,7 +60,7 @@ func repoInfo(c *cli.Context) error {
// template for repo information
var tmplRepoInfo = `Owner: {{ .Owner }}
Repo: {{ .Name }}
Link: {{ .Link }}
URL: {{ .ForgeURL }}
Config path: {{ .Config }}
Visibility: {{ .Visibility }}
Private: {{ .IsSCMPrivate }}

View file

@ -3963,12 +3963,12 @@ const docTemplate = `{
"finished_at": {
"type": "integer"
},
"forge_url": {
"type": "string"
},
"id": {
"type": "integer"
},
"link_url": {
"type": "string"
},
"message": {
"type": "string"
},
@ -4111,6 +4111,9 @@ const docTemplate = `{
"description": "ForgeRemoteID is the unique identifier for the repository on the forge.",
"type": "string"
},
"forge_url": {
"type": "string"
},
"full_name": {
"type": "string"
},
@ -4120,9 +4123,6 @@ const docTemplate = `{
"id": {
"type": "integer"
},
"link_url": {
"type": "string"
},
"name": {
"type": "string"
},

View file

@ -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)
- Deprecated `CI_COMMIT_URL` env var, use `CI_PIPELINE_FORGE_URL`
## 1.0.0

View file

@ -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,
ForgeURL: repo.ForgeURL,
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,
ForgeURL: pipeline.ForgeURL,
Target: pipeline.Deploy,
Commit: metadata.Commit{
Sha: pipeline.Commit,

View file

@ -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.ForgeURL,
"CI_REPO_CLONE_URL": m.Repo.CloneURL,
"CI_REPO_CLONE_SSH_URL": m.Repo.CloneSSHURL,
"CI_REPO_DEFAULT_BRANCH": m.Repo.Branch,
@ -69,7 +69,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.getPipelineWebURL(m.Curr, 0),
"CI_PIPELINE_FORGE_URL": m.Curr.Link,
"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),
@ -90,7 +90,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.Link,
"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,
@ -100,7 +100,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.getPipelineWebURL(m.Prev, 0),
"CI_PREV_PIPELINE_FORGE_URL": m.Prev.Link,
"CI_PREV_PIPELINE_FORGE_URL": m.Prev.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),
@ -108,7 +108,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,
@ -117,7 +117,7 @@ func (m *Metadata) Environ() map[string]string {
"CI_FORGE_URL": m.Forge.URL,
// TODO Deprecated, remove in 3.x
"CI_COMMIT_URL": m.Curr.Link,
"CI_COMMIT_URL": m.Curr.ForgeURL,
}
if m.Curr.Event == EventTag {
params["CI_COMMIT_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/")
@ -132,8 +132,8 @@ func (m *Metadata) Environ() map[string]string {
func (m *Metadata) getPipelineWebURL(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)
}

View file

@ -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"`
ForgeURL string `json:"forge_url,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"`
ForgeURL string `json:"forge_url,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:"url,omitempty"`
Platform string `json:"arch,omitempty"`
Version string `json:"version,omitempty"`
}

View file

@ -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
}{
@ -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", 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"},
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", 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", 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"},
@ -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())
})

View file

@ -60,7 +60,7 @@ func TestCompilerCompile(t *testing.T) {
Owner: "octacat",
Name: "hello-world",
Private: true,
Link: "https://github.com/octocat/hello-world",
ForgeURL: "https://github.com/octocat/hello-world",
CloneURL: "https://github.com/octocat/hello-world.git",
},
}),

View file

@ -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)
}

View file

@ -115,7 +115,7 @@ func TestWithMetadata(t *testing.T) {
Owner: "octacat",
Name: "hello-world",
Private: true,
Link: "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.Link {
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 {

View file

@ -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
@ -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.ForgeURL),
compiler.WithMetadata(metadata),
compiler.WithTrusted(b.Repo.IsTrusted),
compiler.WithNetrcOnlyTrusted(b.Repo.NetrcOnlyTrusted),

View file

@ -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

View file

@ -87,8 +87,8 @@ func createTmpPipeline(event model.WebhookEvent, commitSHA string, repo *model.R
Author: user.Login,
Email: user.Email,
// TODO: Generate proper link to commit
Link: repo.Link,
// TODO: Generate proper URL to commit
ForgeURL: repo.ForgeURL,
}
}

View file

@ -117,7 +117,7 @@ func PostRepo(c *gin.Context) {
return
}
link := fmt.Sprintf(
hookURL := fmt.Sprintf(
"%s/api/hook?access_token=%s",
server.Config.Server.WebhookHost,
sig,
@ -148,7 +148,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
@ -483,9 +483,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,
@ -494,7 +494,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
}
@ -571,9 +571,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,
@ -613,7 +613,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
}

View file

@ -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",

View file

@ -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,
ForgeURL: repo.ForgeURL,
}, nil
}

View file

@ -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)
}

View file

@ -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,
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),
Link: 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,
Link: 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,

View file

@ -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.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.Link).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.Link).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())

View file

@ -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)
}

View file

@ -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),
},

View file

@ -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.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)

View file

@ -43,7 +43,7 @@ func toRepo(from *gitea.Repository) *model.Repo {
Owner: from.Owner.UserName,
FullName: from.FullName,
Avatar: avatar,
Link: 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,
Link: 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),
Link: 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,
Link: 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,

View file

@ -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.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.Link).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.Link).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.Link).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.Link).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.Link).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)

View file

@ -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(),
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(),
Link: eventRepo.GetHTMLURL(),
ForgeURL: eventRepo.GetHTMLURL(),
IsSCMPrivate: eventRepo.GetPrivate(),
Clone: eventRepo.GetCloneURL(),
CloneSSH: eventRepo.GetSSHURL(),

View file

@ -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.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.Link).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.Link).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.Link).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)

View file

@ -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.ForgeURL)
if len(matches) != 2 {
return nil
}
@ -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
}

View file

@ -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.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",
Link: "https://github.com/octocat/Hello-World",
ForgeURL: "https://github.com/octocat/Hello-World",
Clone: "https://github.com/octocat/Hello-World.git",
IsSCMPrivate: true,
}

View file

@ -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(),
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(),
Link: 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(),
Link: hook.GetPullRequest().GetHTMLURL(),
ForgeURL: hook.GetPullRequest().GetHTMLURL(),
Ref: fmt.Sprintf(headRefs, hook.GetPullRequest().GetNumber()),
Branch: hook.GetPullRequest().GetBase().GetRef(),
Message: hook.GetPullRequest().GetTitle(),

View file

@ -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,
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.Link = 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.Link = 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.Link = 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.Link = hook.Project.WebURL
repo.ForgeURL = hook.Project.WebURL
repo.Clone = hook.Project.GitHTTPURL
repo.CloneSSH = hook.Project.GitSSHURL
repo.FullName = hook.Project.PathWithNamespace

View file

@ -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))

View file

@ -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"`
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:"-"`

View file

@ -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'"`
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.Link = from.Link
r.ForgeURL = from.ForgeURL
r.SCMKind = from.SCMKind
if len(from.Clone) > 0 {
r.Clone = from.Clone

View file

@ -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{

View file

@ -36,6 +36,26 @@ func (oldSecret021) TableName() string {
return "secrets"
}
type syncRepo021 struct {
OrgID int64 `json:"org_id" xorm:"repo_org_id"`
}
// TableName return database table name for xorm
func (syncRepo021) TableName() string {
return "repos"
}
type repo021 struct {
ID int64 `json:"id,omitempty" xorm:"pk autoincr 'repo_id'"`
OrgID int64 `json:"org_id" xorm:"repo_org_id"`
Owner string `json:"owner" xorm:"UNIQUE(name) 'repo_owner'"`
}
// TableName return database table name for xorm
func (repo021) TableName() string {
return "repos"
}
var addOrgs = task{
name: "add-orgs",
required: true,
@ -46,7 +66,7 @@ var addOrgs = task{
}
}
if err := sess.Sync(new(model.Org), new(model.Repo), new(model.User)); err != nil {
if err := sess.Sync(new(model.Org), new(syncRepo021), new(model.User)); err != nil {
return fmt.Errorf("sync new models failed: %w", err)
}
@ -56,7 +76,7 @@ var addOrgs = task{
}
// get all org names from repos
var repos []*model.Repo
var repos []*repo021
if err := sess.Find(&repos); err != nil {
return fmt.Errorf("find all repos failed: %w", err)
}

View file

@ -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_forge_url"); err != nil {
return err
}
return renameColumn(sess, "repos", "repo_link", "repo_forge_url")
},
}

View file

@ -59,6 +59,7 @@ var migrationTasks = []*task{
&alterTableConfigUpdateColumnConfigDataType,
&removePluginOnlyOptionFromSecretsTable,
&convertToNewPipelineErrorFormat,
&renameLinkToURL,
}
var allBeans = []any{

View file

@ -13,7 +13,7 @@
<a
v-if="pipeline.event === 'pull_request'"
class="flex items-center space-x-1 text-wp-link-100 hover:text-wp-link-200 min-w-0"
:href="pipeline.link_url"
:href="pipeline.forge_url"
>
<Icon name="pull_request" />
<span class="truncate">{{ prettyRef }}</span>
@ -41,7 +41,7 @@
<a
v-else
class="text-wp-link-100 hover:text-wp-link-200 flex items-center"
:href="pipeline.link_url"
:href="pipeline.forge_url"
target="_blank"
>
<Icon name="commit" />

View file

@ -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.
forge_url: string;
signed: boolean;

View file

@ -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.
forge_url: string;
// The url used to clone the repository.
clone_url: string;

View file

@ -17,7 +17,7 @@
<a v-if="badgeUrl" :href="badgeUrl" target="_blank">
<img :src="badgeUrl" />
</a>
<IconButton :href="repo.link_url" :title="$t('repo.open_in_forge')" :icon="forge ?? 'repo'" />
<IconButton :href="repo.forge_url" :title="$t('repo.open_in_forge')" :icon="forge ?? 'repo'" />
<IconButton
v-if="repoPermissions.admin"
:to="{ name: 'repo-settings' }"

View file

@ -39,7 +39,7 @@
color="blue"
:start-icon="forge ?? 'repo'"
:text="$t('repo.pipeline.protected.review')"
:to="pipeline.link_url"
:to="pipeline.forge_url"
:title="message"
/>
<Button

View file

@ -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"`
ForgeURL string `json:"forge_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"`
ForgeURL string `json:"forge_url"`
Reviewer string `json:"reviewed_by"`
Reviewed int64 `json:"reviewed_at"`
Workflows []*Workflow `json:"workflows,omitempty"`