mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 12:21:03 +00:00
Merge pull request #1757 from appleboy/patch-4
Testing author label length limitation for Bitbucket server. [CI SKIP]
This commit is contained in:
commit
fe750c751a
3 changed files with 59 additions and 65 deletions
|
@ -67,15 +67,14 @@ func convertPushHook(hook *internal.PostHook, baseURL string) *model.Build {
|
||||||
name := refParts[2]
|
name := refParts[2]
|
||||||
commitType := refParts[1]
|
commitType := refParts[1]
|
||||||
|
|
||||||
|
|
||||||
//Ensuring the author label is not longer then 40 for the label of the commit author (default size in the db)
|
//Ensuring the author label is not longer then 40 for the label of the commit author (default size in the db)
|
||||||
authorLabel := hook.Changesets.Values[0].ToCommit.Author.Name
|
authorLabel := hook.Changesets.Values[0].ToCommit.Author.Name
|
||||||
if (len(authorLabel) > 40) {
|
if len(authorLabel) > 40 {
|
||||||
authorLabel = authorLabel[0:40]
|
authorLabel = authorLabel[0:37] + "..."
|
||||||
}
|
}
|
||||||
|
|
||||||
build := &model.Build{
|
build := &model.Build{
|
||||||
Commit: hook.RefChanges[0].ToHash, // TODO check for index value
|
Commit: hook.RefChanges[0].ToHash, // TODO check for index value
|
||||||
Branch: name,
|
Branch: name,
|
||||||
Message: hook.Changesets.Values[0].ToCommit.Message, //TODO check for index Values
|
Message: hook.Changesets.Values[0].ToCommit.Message, //TODO check for index Values
|
||||||
Avatar: avatarLink(hook.Changesets.Values[0].ToCommit.Author.EmailAddress),
|
Avatar: avatarLink(hook.Changesets.Values[0].ToCommit.Author.EmailAddress),
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package bitbucketserver
|
package bitbucketserver
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"github.com/drone/drone/model"
|
"github.com/drone/drone/model"
|
||||||
"github.com/drone/drone/remote/bitbucketserver/internal"
|
"github.com/drone/drone/remote/bitbucketserver/internal"
|
||||||
"github.com/franela/goblin"
|
"github.com/franela/goblin"
|
||||||
"github.com/mrjones/oauth"
|
"github.com/mrjones/oauth"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_helper(t *testing.T) {
|
func Test_helper(t *testing.T) {
|
||||||
|
@ -14,7 +13,6 @@ func Test_helper(t *testing.T) {
|
||||||
g := goblin.Goblin(t)
|
g := goblin.Goblin(t)
|
||||||
g.Describe("Bitbucket Server converter", func() {
|
g.Describe("Bitbucket Server converter", func() {
|
||||||
|
|
||||||
|
|
||||||
g.It("should convert repository lite", func() {
|
g.It("should convert repository lite", func() {
|
||||||
from := &internal.Repo{}
|
from := &internal.Repo{}
|
||||||
from.Project.Key = "octocat"
|
from.Project.Key = "octocat"
|
||||||
|
@ -26,7 +24,6 @@ func Test_helper(t *testing.T) {
|
||||||
g.Assert(to.Name).Equal("hello-world")
|
g.Assert(to.Name).Equal("hello-world")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
g.It("should convert repository", func() {
|
g.It("should convert repository", func() {
|
||||||
from := &internal.Repo{
|
from := &internal.Repo{
|
||||||
Slug: "hello-world",
|
Slug: "hello-world",
|
||||||
|
@ -62,7 +59,7 @@ func Test_helper(t *testing.T) {
|
||||||
Token: "foo",
|
Token: "foo",
|
||||||
}
|
}
|
||||||
user := &internal.User{
|
user := &internal.User{
|
||||||
Slug: "x12f",
|
Slug: "x12f",
|
||||||
EmailAddress: "huh@huh.com",
|
EmailAddress: "huh@huh.com",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,18 +69,16 @@ func Test_helper(t *testing.T) {
|
||||||
g.Assert(result.Token).Equal("foo")
|
g.Assert(result.Token).Equal("foo")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g.It("should convert push hook to build", func() {
|
g.It("should convert push hook to build", func() {
|
||||||
change := internal.PostHook{}
|
change := internal.PostHook{}
|
||||||
|
|
||||||
change.RefChanges = append(change.RefChanges, internal.RefChange{
|
change.RefChanges = append(change.RefChanges, internal.RefChange{
|
||||||
RefID: "refs/heads/master",
|
RefID: "refs/heads/master",
|
||||||
ToHash: "73f9c44d",
|
ToHash: "73f9c44d",
|
||||||
})
|
})
|
||||||
|
|
||||||
value := internal.Value{}
|
value := internal.Value{}
|
||||||
value.ToCommit.Author.Name = "John Doe"
|
value.ToCommit.Author.Name = "John Doe, Appleboy, Mary, Janet E. Dawson and Ann S. Palmer"
|
||||||
value.ToCommit.Author.EmailAddress = "huh@huh.com"
|
value.ToCommit.Author.EmailAddress = "huh@huh.com"
|
||||||
value.ToCommit.Message = "message"
|
value.ToCommit.Message = "message"
|
||||||
|
|
||||||
|
@ -94,7 +89,8 @@ func Test_helper(t *testing.T) {
|
||||||
|
|
||||||
build := convertPushHook(&change, "http://base.com")
|
build := convertPushHook(&change, "http://base.com")
|
||||||
g.Assert(build.Event).Equal(model.EventPush)
|
g.Assert(build.Event).Equal(model.EventPush)
|
||||||
g.Assert(build.Author).Equal("John Doe")
|
// Ensuring the author label is not longer then 40
|
||||||
|
g.Assert(build.Author).Equal("John Doe, Appleboy, Mary, Janet E. Da...")
|
||||||
g.Assert(build.Avatar).Equal(avatarLink("huh@huh.com"))
|
g.Assert(build.Avatar).Equal(avatarLink("huh@huh.com"))
|
||||||
g.Assert(build.Commit).Equal("73f9c44d")
|
g.Assert(build.Commit).Equal("73f9c44d")
|
||||||
g.Assert(build.Branch).Equal("master")
|
g.Assert(build.Branch).Equal("master")
|
||||||
|
@ -106,7 +102,7 @@ func Test_helper(t *testing.T) {
|
||||||
g.It("should convert tag hook to build", func() {
|
g.It("should convert tag hook to build", func() {
|
||||||
change := internal.PostHook{}
|
change := internal.PostHook{}
|
||||||
change.RefChanges = append(change.RefChanges, internal.RefChange{
|
change.RefChanges = append(change.RefChanges, internal.RefChange{
|
||||||
RefID: "refs/tags/v1",
|
RefID: "refs/tags/v1",
|
||||||
ToHash: "73f9c44d",
|
ToHash: "73f9c44d",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ type Repo struct {
|
||||||
Forkable bool `json:"forkable"`
|
Forkable bool `json:"forkable"`
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Links struct {
|
Links struct {
|
||||||
Clone []CloneLink`json:"clone"`
|
Clone []CloneLink `json:"clone"`
|
||||||
Self []struct {
|
Self []struct {
|
||||||
Href string `json:"href"`
|
Href string `json:"href"`
|
||||||
} `json:"self"`
|
} `json:"self"`
|
||||||
} `json:"links"`
|
} `json:"links"`
|
||||||
|
@ -76,56 +76,55 @@ type HookDetail struct {
|
||||||
|
|
||||||
type Value struct {
|
type Value struct {
|
||||||
Changes struct {
|
Changes struct {
|
||||||
Filter interface{} `json:"filter"`
|
Filter interface{} `json:"filter"`
|
||||||
IsLastPage bool `json:"isLastPage"`
|
IsLastPage bool `json:"isLastPage"`
|
||||||
Limit int `json:"limit"`
|
Limit int `json:"limit"`
|
||||||
Size int `json:"size"`
|
Size int `json:"size"`
|
||||||
Start int `json:"start"`
|
Start int `json:"start"`
|
||||||
Values []struct {
|
Values []struct {
|
||||||
ContentID string `json:"contentId"`
|
ContentID string `json:"contentId"`
|
||||||
Executable bool `json:"executable"`
|
Executable bool `json:"executable"`
|
||||||
Link struct {
|
Link struct {
|
||||||
Rel string `json:"rel"`
|
Rel string `json:"rel"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
} `json:"link"`
|
} `json:"link"`
|
||||||
NodeType string `json:"nodeType"`
|
NodeType string `json:"nodeType"`
|
||||||
Path struct {
|
Path struct {
|
||||||
Components []string `json:"components"`
|
Components []string `json:"components"`
|
||||||
Extension string `json:"extension"`
|
Extension string `json:"extension"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Parent string `json:"parent"`
|
Parent string `json:"parent"`
|
||||||
ToString string `json:"toString"`
|
ToString string `json:"toString"`
|
||||||
} `json:"path"`
|
} `json:"path"`
|
||||||
PercentUnchanged int `json:"percentUnchanged"`
|
PercentUnchanged int `json:"percentUnchanged"`
|
||||||
SrcExecutable bool `json:"srcExecutable"`
|
SrcExecutable bool `json:"srcExecutable"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
} `json:"values"`
|
} `json:"values"`
|
||||||
} `json:"changes"`
|
} `json:"changes"`
|
||||||
FromCommit struct {
|
FromCommit struct {
|
||||||
|
DisplayID string `json:"displayId"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
} `json:"fromCommit"`
|
||||||
|
Link struct {
|
||||||
|
Rel string `json:"rel"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
} `json:"link"`
|
||||||
|
ToCommit struct {
|
||||||
|
Author struct {
|
||||||
|
EmailAddress string `json:"emailAddress"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
} `json:"author"`
|
||||||
|
AuthorTimestamp int `json:"authorTimestamp"`
|
||||||
|
DisplayID string `json:"displayId"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Parents []struct {
|
||||||
DisplayID string `json:"displayId"`
|
DisplayID string `json:"displayId"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
} `json:"fromCommit"`
|
} `json:"parents"`
|
||||||
Link struct {
|
} `json:"toCommit"`
|
||||||
Rel string `json:"rel"`
|
|
||||||
URL string `json:"url"`
|
|
||||||
} `json:"link"`
|
|
||||||
ToCommit struct {
|
|
||||||
Author struct {
|
|
||||||
EmailAddress string `json:"emailAddress"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
} `json:"author"`
|
|
||||||
AuthorTimestamp int `json:"authorTimestamp"`
|
|
||||||
DisplayID string `json:"displayId"`
|
|
||||||
ID string `json:"id"`
|
|
||||||
Message string `json:"message"`
|
|
||||||
Parents []struct {
|
|
||||||
DisplayID string `json:"displayId"`
|
|
||||||
ID string `json:"id"`
|
|
||||||
} `json:"parents"`
|
|
||||||
} `json:"toCommit"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type PostHook struct {
|
type PostHook struct {
|
||||||
Changesets struct {
|
Changesets struct {
|
||||||
Filter interface{} `json:"filter"`
|
Filter interface{} `json:"filter"`
|
||||||
|
@ -133,7 +132,7 @@ type PostHook struct {
|
||||||
Limit int `json:"limit"`
|
Limit int `json:"limit"`
|
||||||
Size int `json:"size"`
|
Size int `json:"size"`
|
||||||
Start int `json:"start"`
|
Start int `json:"start"`
|
||||||
Values []Value `json:"values"`
|
Values []Value `json:"values"`
|
||||||
} `json:"changesets"`
|
} `json:"changesets"`
|
||||||
RefChanges []RefChange `json:"refChanges"`
|
RefChanges []RefChange `json:"refChanges"`
|
||||||
Repository struct {
|
Repository struct {
|
||||||
|
@ -156,7 +155,7 @@ type PostHook struct {
|
||||||
} `json:"repository"`
|
} `json:"repository"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RefChange struct {
|
type RefChange struct {
|
||||||
FromHash string `json:"fromHash"`
|
FromHash string `json:"fromHash"`
|
||||||
RefID string `json:"refId"`
|
RefID string `json:"refId"`
|
||||||
ToHash string `json:"toHash"`
|
ToHash string `json:"toHash"`
|
||||||
|
|
Loading…
Reference in a new issue