1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2026-06-03 16:35:37 +02:00

Change master to main (#2044)

This commit is contained in:
Anbraten
2023-07-31 05:47:23 +02:00
committed by GitHub
parent 7efb15bf9c
commit e0ed1b3e49
48 changed files with 235 additions and 270 deletions
+5 -5
View File
@@ -125,7 +125,7 @@ func Test_helper(t *testing.T) {
hook.Actor.Login = "octocat"
hook.Actor.Links.Avatar.Href = "https://..."
hook.PullRequest.Dest.Commit.Hash = "73f9c44d"
hook.PullRequest.Dest.Branch.Name = "master"
hook.PullRequest.Dest.Branch.Name = "main"
hook.PullRequest.Dest.Repo.Links.HTML.Href = "https://bitbucket.org/foo/bar"
hook.PullRequest.Source.Branch.Name = "change"
hook.PullRequest.Source.Repo.FullName = "baz/bar"
@@ -140,8 +140,8 @@ func Test_helper(t *testing.T) {
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.Ref).Equal("refs/heads/master")
g.Assert(pipeline.Refspec).Equal("change:master")
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")
g.Assert(pipeline.Message).Equal(hook.PullRequest.Desc)
g.Assert(pipeline.Timestamp).Equal(hook.PullRequest.Updated.Unix())
@@ -150,7 +150,7 @@ func Test_helper(t *testing.T) {
g.It("should convert push hook to pipeline", func() {
change := internal.Change{}
change.New.Target.Hash = "73f9c44d"
change.New.Name = "master"
change.New.Name = "main"
change.New.Target.Links.HTML.Href = "https://bitbucket.org/foo/bar/commits/73f9c44d"
change.New.Target.Message = "updated README"
change.New.Target.Date = time.Now()
@@ -168,7 +168,7 @@ func Test_helper(t *testing.T) {
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.Ref).Equal("refs/heads/master")
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())
})
+9 -9
View File
@@ -111,7 +111,7 @@ const HookPush = `
"changes": [
{
"old": {
"name": "master",
"name": "main",
"target": {
"type": "commit",
"hash": "a51241ae1f00cbe728930db48e890b18fd527f99",
@@ -159,13 +159,13 @@ const HookPush = `
},
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/martinherren1984/publictestrepo/refs/branches/master"
"href": "https://api.bitbucket.org/2.0/repositories/martinherren1984/publictestrepo/refs/branches/main"
},
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/martinherren1984/publictestrepo/commits/master"
"href": "https://api.bitbucket.org/2.0/repositories/martinherren1984/publictestrepo/commits/main"
},
"html": {
"href": "https://bitbucket.org/martinherren1984/publictestrepo/branch/master"
"href": "https://bitbucket.org/martinherren1984/publictestrepo/branch/main"
}
},
"type": "branch",
@@ -177,7 +177,7 @@ const HookPush = `
"default_merge_strategy": "merge_commit"
},
"new": {
"name": "master",
"name": "main",
"target": {
"type": "commit",
"hash": "c14c1bb05dfb1fdcdf06b31485fff61b0ea44277",
@@ -238,13 +238,13 @@ const HookPush = `
},
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/martinherren1984/publictestrepo/refs/branches/master"
"href": "https://api.bitbucket.org/2.0/repositories/martinherren1984/publictestrepo/refs/branches/main"
},
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/martinherren1984/publictestrepo/commits/master"
"href": "https://api.bitbucket.org/2.0/repositories/martinherren1984/publictestrepo/commits/main"
},
"html": {
"href": "https://bitbucket.org/martinherren1984/publictestrepo/branch/master"
"href": "https://bitbucket.org/martinherren1984/publictestrepo/branch/main"
}
},
"type": "branch",
@@ -412,7 +412,7 @@ const HookPull = `
},
"destination": {
"branch": {
"name": "master"
"name": "main"
},
"commit": {
"hash": "ce5965ddd289"
+7 -7
View File
@@ -17,7 +17,7 @@ package fixtures
// HookPush is a sample Gitea push hook
const HookPush = `
{
"ref": "refs/heads/master",
"ref": "refs/heads/main",
"before": "4b2626259b5a97b6b4eab5e6cca66adb986b672b",
"after": "ef98532add3b2feb7a137426bba1248724367df5",
"compare_url": "http://gitea.golang.org/gordon/hello-world/compare/4b2626259b5a97b6b4eab5e6cca66adb986b672b...ef98532add3b2feb7a137426bba1248724367df5",
@@ -81,7 +81,7 @@ const HookPushBranch = `
"ref": "refs/heads/fdsafdsa",
"before": "0000000000000000000000000000000000000000",
"after": "28c3613ae62640216bea5e7dc71aa65356e4298b",
"compare_url": "https://codeberg.org/meisam/woodpecktester/compare/master...28c3613ae62640216bea5e7dc71aa65356e4298b",
"compare_url": "https://codeberg.org/meisam/woodpecktester/compare/main...28c3613ae62640216bea5e7dc71aa65356e4298b",
"commits": [],
"head_commit": {
"id": "28c3613ae62640216bea5e7dc71aa65356e4298b",
@@ -157,7 +157,7 @@ const HookPushBranch = `
"open_issues_count": 0,
"open_pr_counter": 0,
"release_counter": 0,
"default_branch": "master",
"default_branch": "main",
"archived": false,
"created_at": "2022-07-04T00:34:39+02:00",
"updated_at": "2022-07-24T20:31:29+02:00",
@@ -253,7 +253,7 @@ const HookPushTag = `{
"html_url": "http://gitea.golang.org/gordon/hello-world",
"ssh_url": "git@gitea.golang.org:gordon/hello-world.git",
"clone_url": "http://gitea.golang.org/gordon/hello-world.git",
"default_branch": "master",
"default_branch": "main",
"created_at": "2015-10-22T19:32:44Z",
"updated_at": "2016-11-24T13:37:16Z",
"permissions": {
@@ -290,8 +290,8 @@ const HookPullRequest = `{
"avatar_url": "http://gitea.golang.org///1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
},
"base": {
"label": "master",
"ref": "master",
"label": "main",
"ref": "main",
"sha": "9353195a19e45482665306e466c832c46560532d"
},
"head": {
@@ -315,7 +315,7 @@ const HookPullRequest = `{
"private": true,
"html_url": "http://gitea.golang.org/gordon/hello-world",
"clone_url": "https://gitea.golang.org/gordon/hello-world.git",
"default_branch": "master",
"default_branch": "main",
"permissions": {
"admin": true,
"push": true,
+8 -8
View File
@@ -34,7 +34,7 @@ func Test_parse(t *testing.T) {
buf := bytes.NewBufferString(fixtures.HookPush)
hook, err := parsePush(buf)
g.Assert(err).IsNil()
g.Assert(hook.Ref).Equal("refs/heads/master")
g.Assert(hook.Ref).Equal("refs/heads/main")
g.Assert(hook.After).Equal("ef98532add3b2feb7a137426bba1248724367df5")
g.Assert(hook.Before).Equal("4b2626259b5a97b6b4eab5e6cca66adb986b672b")
g.Assert(hook.Compare).Equal("http://gitea.golang.org/gordon/hello-world/compare/4b2626259b5a97b6b4eab5e6cca66adb986b672b...ef98532add3b2feb7a137426bba1248724367df5")
@@ -86,8 +86,8 @@ func Test_parse(t *testing.T) {
g.Assert(hook.PullRequest.Body).Equal("please merge")
g.Assert(hook.PullRequest.State).Equal(gitea.StateOpen)
g.Assert(hook.PullRequest.Poster.UserName).Equal("gordon")
g.Assert(hook.PullRequest.Base.Name).Equal("master")
g.Assert(hook.PullRequest.Base.Ref).Equal("master")
g.Assert(hook.PullRequest.Base.Name).Equal("main")
g.Assert(hook.PullRequest.Base.Ref).Equal("main")
g.Assert(hook.PullRequest.Head.Name).Equal("feature/changes")
g.Assert(hook.PullRequest.Head.Ref).Equal("feature/changes")
})
@@ -100,7 +100,7 @@ func Test_parse(t *testing.T) {
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.Branch).Equal("master")
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")
g.Assert(pipeline.Author).Equal(hook.Sender.UserName)
@@ -137,8 +137,8 @@ func Test_parse(t *testing.T) {
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.Branch).Equal("master")
g.Assert(pipeline.Refspec).Equal("feature/changes:master")
g.Assert(pipeline.Branch).Equal("main")
g.Assert(pipeline.Refspec).Equal("feature/changes:main")
g.Assert(pipeline.Message).Equal(hook.PullRequest.Title)
g.Assert(pipeline.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
g.Assert(pipeline.Author).Equal(hook.PullRequest.Poster.UserName)
@@ -201,14 +201,14 @@ func Test_parse(t *testing.T) {
CloneURL: "http://gitea.golang.org/gophers/hello-world.git",
HTMLURL: "http://gitea.golang.org/gophers/hello-world",
Private: true,
DefaultBranch: "master",
DefaultBranch: "main",
Permissions: &gitea.Permission{Admin: true},
}
repo := toRepo(&from)
g.Assert(repo.FullName).Equal(from.FullName)
g.Assert(repo.Owner).Equal(from.Owner.UserName)
g.Assert(repo.Name).Equal("hello-world")
g.Assert(repo.Branch).Equal("master")
g.Assert(repo.Branch).Equal("main")
g.Assert(repo.Link).Equal(from.HTMLURL)
g.Assert(repo.Clone).Equal(from.CloneURL)
g.Assert(repo.Avatar).Equal(from.Owner.AvatarURL)
+11 -11
View File
@@ -188,7 +188,7 @@ func Test_helper(t *testing.T) {
Number: github.Int(42),
Title: github.String("Updated README.md"),
Base: &github.PullRequestBranch{
Ref: github.String("master"),
Ref: github.String("main"),
},
Head: &github.PullRequestBranch{
Ref: github.String("changes"),
@@ -211,7 +211,7 @@ func Test_helper(t *testing.T) {
g.Assert(pipeline.Event).Equal(model.EventPull)
g.Assert(pipeline.Branch).Equal(*from.PullRequest.Base.Ref)
g.Assert(pipeline.Ref).Equal("refs/pull/42/merge")
g.Assert(pipeline.Refspec).Equal("changes:master")
g.Assert(pipeline.Refspec).Equal("changes:main")
g.Assert(pipeline.CloneURL).Equal("https://github.com/octocat/hello-world-fork")
g.Assert(pipeline.Commit).Equal(*from.PullRequest.Head.SHA)
g.Assert(pipeline.Message).Equal(*from.PullRequest.Title)
@@ -226,7 +226,7 @@ func Test_helper(t *testing.T) {
from.Deployment.Description = github.String(":shipit:")
from.Deployment.Environment = github.String("production")
from.Deployment.ID = github.Int64(42)
from.Deployment.Ref = github.String("master")
from.Deployment.Ref = github.String("main")
from.Deployment.SHA = github.String("f72fc19")
from.Deployment.URL = github.String("https://github.com/octocat/hello-world")
from.Sender.Login = github.String("octocat")
@@ -235,8 +235,8 @@ func Test_helper(t *testing.T) {
_, pipeline, err := parseDeployHook(from)
g.Assert(err).IsNil()
g.Assert(pipeline.Event).Equal(model.EventDeploy)
g.Assert(pipeline.Branch).Equal("master")
g.Assert(pipeline.Ref).Equal("refs/heads/master")
g.Assert(pipeline.Branch).Equal("main")
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)
@@ -253,13 +253,13 @@ func Test_helper(t *testing.T) {
from.HeadCommit.Message = github.String("updated README.md")
from.HeadCommit.URL = github.String("https://github.com/octocat/hello-world")
from.HeadCommit.ID = github.String("f72fc19")
from.Ref = github.String("refs/heads/master")
from.Ref = github.String("refs/heads/main")
_, pipeline, err := parsePushHook(from)
g.Assert(err).IsNil()
g.Assert(pipeline.Event).Equal(model.EventPush)
g.Assert(pipeline.Branch).Equal("master")
g.Assert(pipeline.Ref).Equal("refs/heads/master")
g.Assert(pipeline.Branch).Equal("main")
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)
@@ -282,18 +282,18 @@ func Test_helper(t *testing.T) {
g.It("should convert tag's base branch from webhook to pipeline's branch ", func() {
from := &github.PushEvent{}
from.Ref = github.String("refs/tags/v1.0.0")
from.BaseRef = github.String("refs/heads/master")
from.BaseRef = github.String("refs/heads/main")
_, pipeline, err := parsePushHook(from)
g.Assert(err).IsNil()
g.Assert(pipeline.Event).Equal(model.EventTag)
g.Assert(pipeline.Branch).Equal("master")
g.Assert(pipeline.Branch).Equal("main")
})
g.It("should not convert tag's base_ref from webhook if not prefixed with 'ref/heads/'", func() {
from := &github.PushEvent{}
from.Ref = github.String("refs/tags/v1.0.0")
from.BaseRef = github.String("refs/refs/master")
from.BaseRef = github.String("refs/refs/main")
_, pipeline, err := parsePushHook(from)
g.Assert(err).IsNil()
+8 -8
View File
@@ -17,7 +17,7 @@ package fixtures
// HookPush is a sample push hook.
// https://developer.github.com/v3/activity/events/types/#pushevent
const HookPush = `{
"ref": "refs/heads/master",
"ref": "refs/heads/main",
"before": "2f780193b136b72bfea4eeb640786a8c4450c7a2",
"after": "366701fde727cb7a9e7f21eb88264f59f6f9b89c",
"repository": {
@@ -131,9 +131,9 @@ const HookPush = `{
"forks": 84,
"open_issues": 123,
"watchers": 659,
"default_branch": "master",
"default_branch": "main",
"stargazers": 659,
"master_branch": "master",
"main_branch": "main",
"organization": "woodpecker-ci"
},
"pusher": {
@@ -263,8 +263,8 @@ const HookPullRequest = `
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
},
"base": {
"label": "baxterthehacker:master",
"ref": "master",
"label": "baxterthehacker:main",
"ref": "main",
"sha": "9353195a19e45482665306e466c832c46560532d"
},
"head": {
@@ -284,7 +284,7 @@ const HookPullRequest = `
"private": true,
"html_url": "https://github.com/baxterthehacker/public-repo",
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
"default_branch": "master"
"default_branch": "main"
},
"sender": {
"login": "octocat",
@@ -322,7 +322,7 @@ const HookDeploy = `
"url": "https://api.github.com/repos/baxterthehacker/public-repo/deployments/710692",
"id": 710692,
"sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b",
"ref": "master",
"ref": "main",
"task": "deploy",
"payload": {
},
@@ -344,7 +344,7 @@ const HookDeploy = `
"private": true,
"html_url": "https://github.com/baxterthehacker/public-repo",
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
"default_branch": "master"
"default_branch": "main"
},
"sender": {
"login": "baxterthehacker",
+1 -1
View File
@@ -149,7 +149,7 @@ func Test_GitLab(t *testing.T) {
assert.Equal(t, "woodpecker", hookRepo.Name)
assert.Equal(t, "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg", hookRepo.Avatar)
assert.Equal(t, "develop", hookRepo.Branch)
assert.Equal(t, "refs/heads/master", pipeline.Ref)
assert.Equal(t, "refs/heads/main", pipeline.Ref)
assert.Equal(t, []string{"cmd/cli/main.go"}, pipeline.ChangedFiles)
}
})
+1 -1
View File
@@ -37,7 +37,7 @@ var ServiceHookPushBody = []byte(`{
"event_name": "push",
"before": "ffe8eb4f91d1fe6bc49f1e610e50e4b5767f0104",
"after": "16862e368d8ab812e48833b741dad720d6e2cb7f",
"ref": "refs/heads/master",
"ref": "refs/heads/main",
"checkout_sha": "16862e368d8ab812e48833b741dad720d6e2cb7f",
"message": null,
"user_id": 2,
+5 -5
View File
@@ -20,7 +20,7 @@ var allProjectsPayload = []byte(`
{
"id": 4,
"description": null,
"default_branch": "master",
"default_branch": "main",
"public": false,
"visibility_level": 0,
"ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git",
@@ -66,7 +66,7 @@ var allProjectsPayload = []byte(`
{
"id": 6,
"description": null,
"default_branch": "master",
"default_branch": "main",
"public": false,
"visibility_level": 0,
"ssh_url_to_repo": "git@example.com:brightbox/puppet.git",
@@ -117,7 +117,7 @@ var notArchivedProjectsPayload = []byte(`
{
"id": 4,
"description": null,
"default_branch": "master",
"default_branch": "main",
"public": false,
"visibility_level": 0,
"ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git",
@@ -167,7 +167,7 @@ var project4Payload = []byte(`
{
"id": 4,
"description": null,
"default_branch": "master",
"default_branch": "main",
"public": false,
"visibility_level": 0,
"ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git",
@@ -216,7 +216,7 @@ var project6Payload = []byte(`
{
"id": 6,
"description": null,
"default_branch": "master",
"default_branch": "main",
"public": false,
"visibility_level": 0,
"ssh_url_to_repo": "git@example.com:brightbox/puppet.git",