You've already forked woodpecker
mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-07-12 22:21:40 +02:00
Use package's structs and fix missing clone (#1172)
Closes #1169 Replaces structs that were added inline in hook structs with structs of the corresponding SDKs. This makes it more readable and error-proof.
This commit is contained in:
@ -75,7 +75,9 @@ func ParseRepo(str string) (user, repo string, err error) {
|
|||||||
|
|
||||||
// Update updates the repository with values from the given Repo.
|
// Update updates the repository with values from the given Repo.
|
||||||
func (r *Repo) Update(from *Repo) {
|
func (r *Repo) Update(from *Repo) {
|
||||||
r.RemoteID = from.RemoteID
|
if from.RemoteID.IsValid() {
|
||||||
|
r.RemoteID = from.RemoteID
|
||||||
|
}
|
||||||
r.Owner = from.Owner
|
r.Owner = from.Owner
|
||||||
r.Name = from.Name
|
r.Name = from.Name
|
||||||
r.FullName = from.FullName
|
r.FullName = from.FullName
|
||||||
|
@ -86,7 +86,9 @@ func Test_helper(t *testing.T) {
|
|||||||
|
|
||||||
change.Changesets.Values = append(change.Changesets.Values, value)
|
change.Changesets.Values = append(change.Changesets.Values, value)
|
||||||
|
|
||||||
change.Repository.Project.Key = "octocat"
|
change.Repository.Project = internal.Project{
|
||||||
|
Key: "octocat",
|
||||||
|
}
|
||||||
change.Repository.Slug = "hello-world"
|
change.Repository.Slug = "hello-world"
|
||||||
build := convertPushHook(&change, "http://base.com")
|
build := convertPushHook(&change, "http://base.com")
|
||||||
g.Assert(build.Branch).Equal("")
|
g.Assert(build.Branch).Equal("")
|
||||||
|
@ -55,23 +55,25 @@ type Repo struct {
|
|||||||
Href string `json:"href"`
|
Href string `json:"href"`
|
||||||
} `json:"self"`
|
} `json:"self"`
|
||||||
} `json:"links"`
|
} `json:"links"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Project struct {
|
Project Project `json:"project"`
|
||||||
Description string `json:"description"`
|
Public bool `json:"public"`
|
||||||
ID int `json:"id"`
|
ScmID string `json:"scmId"`
|
||||||
Key string `json:"key"`
|
Slug string `json:"slug"`
|
||||||
Links struct {
|
State string `json:"state"`
|
||||||
Self []SelfRefLink `json:"self"`
|
StatusMessage string `json:"statusMessage"`
|
||||||
} `json:"links"`
|
}
|
||||||
Name string `json:"name"`
|
|
||||||
Public bool `json:"public"`
|
type Project struct {
|
||||||
Type string `json:"type"`
|
Description string `json:"description"`
|
||||||
} `json:"project"`
|
ID int `json:"id"`
|
||||||
Public bool `json:"public"`
|
Key string `json:"key"`
|
||||||
ScmID string `json:"scmId"`
|
Links struct {
|
||||||
Slug string `json:"slug"`
|
Self []SelfRefLink `json:"self"`
|
||||||
State string `json:"state"`
|
} `json:"links"`
|
||||||
StatusMessage string `json:"statusMessage"`
|
Name string `json:"name"`
|
||||||
|
Public bool `json:"public"`
|
||||||
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Repos struct {
|
type Repos struct {
|
||||||
@ -157,24 +159,7 @@ type PostHook struct {
|
|||||||
Values []Value `json:"values"`
|
Values []Value `json:"values"`
|
||||||
} `json:"changesets"`
|
} `json:"changesets"`
|
||||||
RefChanges []RefChange `json:"refChanges"`
|
RefChanges []RefChange `json:"refChanges"`
|
||||||
Repository struct {
|
Repository Repo `json:"repository"`
|
||||||
Forkable bool `json:"forkable"`
|
|
||||||
ID int `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Project struct {
|
|
||||||
ID int `json:"id"`
|
|
||||||
IsPersonal bool `json:"isPersonal"`
|
|
||||||
Key string `json:"key"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Public bool `json:"public"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
} `json:"project"`
|
|
||||||
Public bool `json:"public"`
|
|
||||||
ScmID string `json:"scmId"`
|
|
||||||
Slug string `json:"slug"`
|
|
||||||
State string `json:"state"`
|
|
||||||
StatusMessage string `json:"statusMessage"`
|
|
||||||
} `json:"repository"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RefChange struct {
|
type RefChange struct {
|
||||||
|
@ -16,7 +16,6 @@ package bitbucketserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||||
@ -31,14 +30,7 @@ func parseHook(r *http.Request, baseURL string) (*model.Repo, *model.Build, erro
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
build := convertPushHook(hook, baseURL)
|
build := convertPushHook(hook, baseURL)
|
||||||
repo := &model.Repo{
|
repo := convertRepo(&hook.Repository)
|
||||||
RemoteID: model.RemoteID(fmt.Sprint(hook.Repository.ID)),
|
|
||||||
Name: hook.Repository.Slug,
|
|
||||||
Owner: hook.Repository.Project.Key,
|
|
||||||
FullName: fmt.Sprintf("%s/%s", hook.Repository.Project.Key, hook.Repository.Slug),
|
|
||||||
Branch: "master",
|
|
||||||
SCMKind: model.RepoGit,
|
|
||||||
}
|
|
||||||
|
|
||||||
return repo, build, nil
|
return repo, build, nil
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,7 @@ func convertRepository(repo *Repository) (*model.Repo, error) {
|
|||||||
Name: repo.Name,
|
Name: repo.Name,
|
||||||
FullName: projectFullName(repo.Owner.GlobalKey, repo.Name),
|
FullName: projectFullName(repo.Owner.GlobalKey, repo.Name),
|
||||||
Link: repo.WebURL,
|
Link: repo.WebURL,
|
||||||
|
Clone: repo.HTTPSURL,
|
||||||
SCMKind: model.RepoGit,
|
SCMKind: model.RepoGit,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ func Test_hook(t *testing.T) {
|
|||||||
Name: "test1",
|
Name: "test1",
|
||||||
FullName: "demo1/test1",
|
FullName: "demo1/test1",
|
||||||
Link: "https://coding.net/u/demo1/p/test1",
|
Link: "https://coding.net/u/demo1/p/test1",
|
||||||
|
Clone: "https://git.coding.net/demo1/test1.git",
|
||||||
SCMKind: model.RepoGit,
|
SCMKind: model.RepoGit,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +97,7 @@ func Test_hook(t *testing.T) {
|
|||||||
Name: "test_project",
|
Name: "test_project",
|
||||||
FullName: "kelvin/test_project",
|
FullName: "kelvin/test_project",
|
||||||
Link: "https://coding.net/u/kelvin/p/test_project",
|
Link: "https://coding.net/u/kelvin/p/test_project",
|
||||||
|
Clone: "https://git.coding.net/kelvin/test_project.git",
|
||||||
SCMKind: model.RepoGit,
|
SCMKind: model.RepoGit,
|
||||||
}
|
}
|
||||||
actual, err := convertRepository(repository)
|
actual, err := convertRepository(repository)
|
||||||
@ -109,6 +111,7 @@ func Test_hook(t *testing.T) {
|
|||||||
Name: "test1",
|
Name: "test1",
|
||||||
FullName: "demo1/test1",
|
FullName: "demo1/test1",
|
||||||
Link: "https://coding.net/u/demo1/p/test1",
|
Link: "https://coding.net/u/demo1/p/test1",
|
||||||
|
Clone: "https://git.coding.net/demo1/test1.git",
|
||||||
SCMKind: model.RepoGit,
|
SCMKind: model.RepoGit,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +147,7 @@ func Test_hook(t *testing.T) {
|
|||||||
Name: "test2",
|
Name: "test2",
|
||||||
FullName: "demo1/test2",
|
FullName: "demo1/test2",
|
||||||
Link: "https://coding.net/u/demo1/p/test2",
|
Link: "https://coding.net/u/demo1/p/test2",
|
||||||
|
Clone: "https://git.coding.net/demo1/test2.git",
|
||||||
SCMKind: model.RepoGit,
|
SCMKind: model.RepoGit,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,6 +177,7 @@ func Test_hook(t *testing.T) {
|
|||||||
Name: "test1",
|
Name: "test1",
|
||||||
FullName: "demo1/test1",
|
FullName: "demo1/test1",
|
||||||
Link: "https://coding.net/u/demo1/p/test1",
|
Link: "https://coding.net/u/demo1/p/test1",
|
||||||
|
Clone: "https://git.coding.net/demo1/test1.git",
|
||||||
SCMKind: model.RepoGit,
|
SCMKind: model.RepoGit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ const HookPush = `
|
|||||||
"owner": {
|
"owner": {
|
||||||
"name": "gordon",
|
"name": "gordon",
|
||||||
"email": "gordon@golang.org",
|
"email": "gordon@golang.org",
|
||||||
|
"login": "gordon",
|
||||||
"username": "gordon"
|
"username": "gordon"
|
||||||
},
|
},
|
||||||
"private": true
|
"private": true
|
||||||
@ -229,6 +230,7 @@ const HookPushTag = `{
|
|||||||
"owner": {
|
"owner": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"username": "gordon",
|
"username": "gordon",
|
||||||
|
"login": "gordon",
|
||||||
"full_name": "Gordon the Gopher",
|
"full_name": "Gordon the Gopher",
|
||||||
"email": "gordon@golang.org",
|
"email": "gordon@golang.org",
|
||||||
"avatar_url": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
|
"avatar_url": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
|
||||||
@ -248,6 +250,7 @@ const HookPushTag = `{
|
|||||||
"sender": {
|
"sender": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"username": "gordon",
|
"username": "gordon",
|
||||||
|
"login": "gordon",
|
||||||
"full_name": "Gordon the Gopher",
|
"full_name": "Gordon the Gopher",
|
||||||
"email": "gordon@golang.org",
|
"email": "gordon@golang.org",
|
||||||
"avatar_url": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
|
"avatar_url": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
|
||||||
@ -266,6 +269,7 @@ const HookPullRequest = `{
|
|||||||
"user": {
|
"user": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"username": "gordon",
|
"username": "gordon",
|
||||||
|
"login": "gordon",
|
||||||
"full_name": "Gordon the Gopher",
|
"full_name": "Gordon the Gopher",
|
||||||
"email": "gordon@golang.org",
|
"email": "gordon@golang.org",
|
||||||
"avatar_url": "http://gitea.golang.org///1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
|
"avatar_url": "http://gitea.golang.org///1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
|
||||||
@ -288,6 +292,7 @@ const HookPullRequest = `{
|
|||||||
"owner": {
|
"owner": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"username": "gordon",
|
"username": "gordon",
|
||||||
|
"login": "gordon",
|
||||||
"full_name": "Gordon the Gopher",
|
"full_name": "Gordon the Gopher",
|
||||||
"email": "gordon@golang.org",
|
"email": "gordon@golang.org",
|
||||||
"avatar_url": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
|
"avatar_url": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
|
||||||
|
@ -69,17 +69,9 @@ func toTeam(from *gitea.Organization, link string) *model.Team {
|
|||||||
// helper function that extracts the Build data from a Gitea push hook
|
// helper function that extracts the Build data from a Gitea push hook
|
||||||
func buildFromPush(hook *pushHook) *model.Build {
|
func buildFromPush(hook *pushHook) *model.Build {
|
||||||
avatar := expandAvatar(
|
avatar := expandAvatar(
|
||||||
hook.Repo.URL,
|
hook.Repo.HTMLURL,
|
||||||
fixMalformedAvatar(hook.Sender.Avatar),
|
fixMalformedAvatar(hook.Sender.AvatarURL),
|
||||||
)
|
)
|
||||||
author := hook.Sender.Login
|
|
||||||
if author == "" {
|
|
||||||
author = hook.Sender.Username
|
|
||||||
}
|
|
||||||
sender := hook.Sender.Username
|
|
||||||
if sender == "" {
|
|
||||||
sender = hook.Sender.Login
|
|
||||||
}
|
|
||||||
|
|
||||||
message := ""
|
message := ""
|
||||||
link := hook.Compare
|
link := hook.Compare
|
||||||
@ -101,10 +93,10 @@ func buildFromPush(hook *pushHook) *model.Build {
|
|||||||
Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"),
|
Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"),
|
||||||
Message: message,
|
Message: message,
|
||||||
Avatar: avatar,
|
Avatar: avatar,
|
||||||
Author: author,
|
Author: hook.Sender.UserName,
|
||||||
Email: hook.Sender.Email,
|
Email: hook.Sender.Email,
|
||||||
Timestamp: time.Now().UTC().Unix(),
|
Timestamp: time.Now().UTC().Unix(),
|
||||||
Sender: sender,
|
Sender: hook.Sender.UserName,
|
||||||
ChangedFiles: getChangedFilesFromPushHook(hook),
|
ChangedFiles: getChangedFilesFromPushHook(hook),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,28 +120,20 @@ func getChangedFilesFromPushHook(hook *pushHook) []string {
|
|||||||
// helper function that extracts the Build data from a Gitea tag hook
|
// helper function that extracts the Build data from a Gitea tag hook
|
||||||
func buildFromTag(hook *pushHook) *model.Build {
|
func buildFromTag(hook *pushHook) *model.Build {
|
||||||
avatar := expandAvatar(
|
avatar := expandAvatar(
|
||||||
hook.Repo.URL,
|
hook.Repo.HTMLURL,
|
||||||
fixMalformedAvatar(hook.Sender.Avatar),
|
fixMalformedAvatar(hook.Sender.AvatarURL),
|
||||||
)
|
)
|
||||||
author := hook.Sender.Login
|
|
||||||
if author == "" {
|
|
||||||
author = hook.Sender.Username
|
|
||||||
}
|
|
||||||
sender := hook.Sender.Username
|
|
||||||
if sender == "" {
|
|
||||||
sender = hook.Sender.Login
|
|
||||||
}
|
|
||||||
|
|
||||||
return &model.Build{
|
return &model.Build{
|
||||||
Event: model.EventTag,
|
Event: model.EventTag,
|
||||||
Commit: hook.Sha,
|
Commit: hook.Sha,
|
||||||
Ref: fmt.Sprintf("refs/tags/%s", hook.Ref),
|
Ref: fmt.Sprintf("refs/tags/%s", hook.Ref),
|
||||||
Link: fmt.Sprintf("%s/src/tag/%s", hook.Repo.URL, hook.Ref),
|
Link: fmt.Sprintf("%s/src/tag/%s", hook.Repo.HTMLURL, hook.Ref),
|
||||||
Branch: fmt.Sprintf("refs/tags/%s", hook.Ref),
|
Branch: fmt.Sprintf("refs/tags/%s", hook.Ref),
|
||||||
Message: fmt.Sprintf("created tag %s", hook.Ref),
|
Message: fmt.Sprintf("created tag %s", hook.Ref),
|
||||||
Avatar: avatar,
|
Avatar: avatar,
|
||||||
Author: author,
|
Author: hook.Sender.UserName,
|
||||||
Sender: sender,
|
Sender: hook.Sender.UserName,
|
||||||
Timestamp: time.Now().UTC().Unix(),
|
Timestamp: time.Now().UTC().Unix(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,13 +141,9 @@ func buildFromTag(hook *pushHook) *model.Build {
|
|||||||
// helper function that extracts the Build data from a Gitea pull_request hook
|
// helper function that extracts the Build data from a Gitea pull_request hook
|
||||||
func buildFromPullRequest(hook *pullRequestHook) *model.Build {
|
func buildFromPullRequest(hook *pullRequestHook) *model.Build {
|
||||||
avatar := expandAvatar(
|
avatar := expandAvatar(
|
||||||
hook.Repo.URL,
|
hook.Repo.HTMLURL,
|
||||||
fixMalformedAvatar(hook.PullRequest.User.Avatar),
|
fixMalformedAvatar(hook.PullRequest.Poster.AvatarURL),
|
||||||
)
|
)
|
||||||
sender := hook.Sender.Username
|
|
||||||
if sender == "" {
|
|
||||||
sender = hook.Sender.Login
|
|
||||||
}
|
|
||||||
build := &model.Build{
|
build := &model.Build{
|
||||||
Event: model.EventPull,
|
Event: model.EventPull,
|
||||||
Commit: hook.PullRequest.Head.Sha,
|
Commit: hook.PullRequest.Head.Sha,
|
||||||
@ -171,9 +151,9 @@ func buildFromPullRequest(hook *pullRequestHook) *model.Build {
|
|||||||
Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number),
|
Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number),
|
||||||
Branch: hook.PullRequest.Base.Ref,
|
Branch: hook.PullRequest.Base.Ref,
|
||||||
Message: hook.PullRequest.Title,
|
Message: hook.PullRequest.Title,
|
||||||
Author: hook.PullRequest.User.Username,
|
Author: hook.PullRequest.Poster.UserName,
|
||||||
Avatar: avatar,
|
Avatar: avatar,
|
||||||
Sender: sender,
|
Sender: hook.Sender.UserName,
|
||||||
Title: hook.PullRequest.Title,
|
Title: hook.PullRequest.Title,
|
||||||
Refspec: fmt.Sprintf("%s:%s",
|
Refspec: fmt.Sprintf("%s:%s",
|
||||||
hook.PullRequest.Head.Ref,
|
hook.PullRequest.Head.Ref,
|
||||||
@ -183,28 +163,6 @@ func buildFromPullRequest(hook *pullRequestHook) *model.Build {
|
|||||||
return build
|
return build
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function that extracts the Repository data from a Gitea push hook
|
|
||||||
func repoFromPush(hook *pushHook) *model.Repo {
|
|
||||||
return &model.Repo{
|
|
||||||
RemoteID: model.RemoteID(fmt.Sprint(hook.Repo.ID)),
|
|
||||||
Name: hook.Repo.Name,
|
|
||||||
Owner: hook.Repo.Owner.Username,
|
|
||||||
FullName: hook.Repo.FullName,
|
|
||||||
Link: hook.Repo.URL,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function that extracts the Repository data from a Gitea pull_request hook
|
|
||||||
func repoFromPullRequest(hook *pullRequestHook) *model.Repo {
|
|
||||||
return &model.Repo{
|
|
||||||
RemoteID: model.RemoteID(fmt.Sprint(hook.Repo.ID)),
|
|
||||||
Name: hook.Repo.Name,
|
|
||||||
Owner: hook.Repo.Owner.Username,
|
|
||||||
FullName: hook.Repo.FullName,
|
|
||||||
Link: hook.Repo.URL,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function that parses a push hook from a read closer.
|
// helper function that parses a push hook from a read closer.
|
||||||
func parsePush(r io.Reader) (*pushHook, error) {
|
func parsePush(r io.Reader) (*pushHook, error) {
|
||||||
push := new(pushHook)
|
push := new(pushHook)
|
||||||
|
@ -38,19 +38,15 @@ func Test_parse(t *testing.T) {
|
|||||||
g.Assert(hook.Before).Equal("4b2626259b5a97b6b4eab5e6cca66adb986b672b")
|
g.Assert(hook.Before).Equal("4b2626259b5a97b6b4eab5e6cca66adb986b672b")
|
||||||
g.Assert(hook.Compare).Equal("http://gitea.golang.org/gordon/hello-world/compare/4b2626259b5a97b6b4eab5e6cca66adb986b672b...ef98532add3b2feb7a137426bba1248724367df5")
|
g.Assert(hook.Compare).Equal("http://gitea.golang.org/gordon/hello-world/compare/4b2626259b5a97b6b4eab5e6cca66adb986b672b...ef98532add3b2feb7a137426bba1248724367df5")
|
||||||
g.Assert(hook.Repo.Name).Equal("hello-world")
|
g.Assert(hook.Repo.Name).Equal("hello-world")
|
||||||
g.Assert(hook.Repo.URL).Equal("http://gitea.golang.org/gordon/hello-world")
|
g.Assert(hook.Repo.HTMLURL).Equal("http://gitea.golang.org/gordon/hello-world")
|
||||||
g.Assert(hook.Repo.Owner.Name).Equal("gordon")
|
g.Assert(hook.Repo.Owner.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
||||||
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
||||||
g.Assert(hook.Repo.Owner.Username).Equal("gordon")
|
|
||||||
g.Assert(hook.Repo.Private).Equal(true)
|
g.Assert(hook.Repo.Private).Equal(true)
|
||||||
g.Assert(hook.Pusher.Name).Equal("gordon")
|
|
||||||
g.Assert(hook.Pusher.Email).Equal("gordon@golang.org")
|
g.Assert(hook.Pusher.Email).Equal("gordon@golang.org")
|
||||||
g.Assert(hook.Pusher.Username).Equal("gordon")
|
g.Assert(hook.Pusher.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Pusher.Login).Equal("gordon")
|
g.Assert(hook.Sender.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Sender.Login).Equal("gordon")
|
g.Assert(hook.Sender.AvatarURL).Equal("http://gitea.golang.org///1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
g.Assert(hook.Sender.Username).Equal("gordon")
|
|
||||||
g.Assert(hook.Sender.Avatar).Equal("http://gitea.golang.org///1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should parse tag hook payload", func() {
|
g.It("Should parse tag hook payload", func() {
|
||||||
@ -60,13 +56,13 @@ func Test_parse(t *testing.T) {
|
|||||||
g.Assert(hook.Ref).Equal("v1.0.0")
|
g.Assert(hook.Ref).Equal("v1.0.0")
|
||||||
g.Assert(hook.Sha).Equal("ef98532add3b2feb7a137426bba1248724367df5")
|
g.Assert(hook.Sha).Equal("ef98532add3b2feb7a137426bba1248724367df5")
|
||||||
g.Assert(hook.Repo.Name).Equal("hello-world")
|
g.Assert(hook.Repo.Name).Equal("hello-world")
|
||||||
g.Assert(hook.Repo.URL).Equal("http://gitea.golang.org/gordon/hello-world")
|
g.Assert(hook.Repo.HTMLURL).Equal("http://gitea.golang.org/gordon/hello-world")
|
||||||
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
||||||
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
||||||
g.Assert(hook.Repo.Owner.Username).Equal("gordon")
|
g.Assert(hook.Repo.Owner.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Repo.Private).Equal(true)
|
g.Assert(hook.Repo.Private).Equal(true)
|
||||||
g.Assert(hook.Sender.Username).Equal("gordon")
|
g.Assert(hook.Sender.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Sender.Avatar).Equal("https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
g.Assert(hook.Sender.AvatarURL).Equal("https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should parse pull_request hook payload", func() {
|
g.It("Should parse pull_request hook payload", func() {
|
||||||
@ -77,21 +73,21 @@ func Test_parse(t *testing.T) {
|
|||||||
g.Assert(hook.Number).Equal(int64(1))
|
g.Assert(hook.Number).Equal(int64(1))
|
||||||
|
|
||||||
g.Assert(hook.Repo.Name).Equal("hello-world")
|
g.Assert(hook.Repo.Name).Equal("hello-world")
|
||||||
g.Assert(hook.Repo.URL).Equal("http://gitea.golang.org/gordon/hello-world")
|
g.Assert(hook.Repo.HTMLURL).Equal("http://gitea.golang.org/gordon/hello-world")
|
||||||
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
||||||
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
||||||
g.Assert(hook.Repo.Owner.Username).Equal("gordon")
|
g.Assert(hook.Repo.Owner.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Repo.Private).Equal(true)
|
g.Assert(hook.Repo.Private).Equal(true)
|
||||||
g.Assert(hook.Sender.Username).Equal("gordon")
|
g.Assert(hook.Sender.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Sender.Avatar).Equal("https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
g.Assert(hook.Sender.AvatarURL).Equal("https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
|
|
||||||
g.Assert(hook.PullRequest.Title).Equal("Update the README with new information")
|
g.Assert(hook.PullRequest.Title).Equal("Update the README with new information")
|
||||||
g.Assert(hook.PullRequest.Body).Equal("please merge")
|
g.Assert(hook.PullRequest.Body).Equal("please merge")
|
||||||
g.Assert(hook.PullRequest.State).Equal("open")
|
g.Assert(hook.PullRequest.State).Equal(gitea.StateOpen)
|
||||||
g.Assert(hook.PullRequest.User.Username).Equal("gordon")
|
g.Assert(hook.PullRequest.Poster.UserName).Equal("gordon")
|
||||||
g.Assert(hook.PullRequest.Base.Label).Equal("master")
|
g.Assert(hook.PullRequest.Base.Name).Equal("master")
|
||||||
g.Assert(hook.PullRequest.Base.Ref).Equal("master")
|
g.Assert(hook.PullRequest.Base.Ref).Equal("master")
|
||||||
g.Assert(hook.PullRequest.Head.Label).Equal("feature/changes")
|
g.Assert(hook.PullRequest.Head.Name).Equal("feature/changes")
|
||||||
g.Assert(hook.PullRequest.Head.Ref).Equal("feature/changes")
|
g.Assert(hook.PullRequest.Head.Ref).Equal("feature/changes")
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -106,18 +102,18 @@ func Test_parse(t *testing.T) {
|
|||||||
g.Assert(build.Branch).Equal("master")
|
g.Assert(build.Branch).Equal("master")
|
||||||
g.Assert(build.Message).Equal(hook.Commits[0].Message)
|
g.Assert(build.Message).Equal(hook.Commits[0].Message)
|
||||||
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
g.Assert(build.Author).Equal(hook.Sender.Login)
|
g.Assert(build.Author).Equal(hook.Sender.UserName)
|
||||||
g.Assert(utils.EqualStringSlice(build.ChangedFiles, []string{"CHANGELOG.md", "app/controller/application.rb"})).IsTrue()
|
g.Assert(utils.EqualStringSlice(build.ChangedFiles, []string{"CHANGELOG.md", "app/controller/application.rb"})).IsTrue()
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should return a Repo struct from a push hook", func() {
|
g.It("Should return a Repo struct from a push hook", func() {
|
||||||
buf := bytes.NewBufferString(fixtures.HookPush)
|
buf := bytes.NewBufferString(fixtures.HookPush)
|
||||||
hook, _ := parsePush(buf)
|
hook, _ := parsePush(buf)
|
||||||
repo := repoFromPush(hook)
|
repo := toRepo(hook.Repo)
|
||||||
g.Assert(repo.Name).Equal(hook.Repo.Name)
|
g.Assert(repo.Name).Equal(hook.Repo.Name)
|
||||||
g.Assert(repo.Owner).Equal(hook.Repo.Owner.Username)
|
g.Assert(repo.Owner).Equal(hook.Repo.Owner.UserName)
|
||||||
g.Assert(repo.FullName).Equal("gordon/hello-world")
|
g.Assert(repo.FullName).Equal("gordon/hello-world")
|
||||||
g.Assert(repo.Link).Equal(hook.Repo.URL)
|
g.Assert(repo.Link).Equal(hook.Repo.HTMLURL)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should return a Build struct from a tag hook", func() {
|
g.It("Should return a Build struct from a tag hook", func() {
|
||||||
@ -144,17 +140,17 @@ func Test_parse(t *testing.T) {
|
|||||||
g.Assert(build.Refspec).Equal("feature/changes:master")
|
g.Assert(build.Refspec).Equal("feature/changes:master")
|
||||||
g.Assert(build.Message).Equal(hook.PullRequest.Title)
|
g.Assert(build.Message).Equal(hook.PullRequest.Title)
|
||||||
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
g.Assert(build.Author).Equal(hook.PullRequest.User.Username)
|
g.Assert(build.Author).Equal(hook.PullRequest.Poster.UserName)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should return a Repo struct from a pull_request hook", func() {
|
g.It("Should return a Repo struct from a pull_request hook", func() {
|
||||||
buf := bytes.NewBufferString(fixtures.HookPullRequest)
|
buf := bytes.NewBufferString(fixtures.HookPullRequest)
|
||||||
hook, _ := parsePullRequest(buf)
|
hook, _ := parsePullRequest(buf)
|
||||||
repo := repoFromPullRequest(hook)
|
repo := toRepo(hook.Repo)
|
||||||
g.Assert(repo.Name).Equal(hook.Repo.Name)
|
g.Assert(repo.Name).Equal(hook.Repo.Name)
|
||||||
g.Assert(repo.Owner).Equal(hook.Repo.Owner.Username)
|
g.Assert(repo.Owner).Equal(hook.Repo.Owner.UserName)
|
||||||
g.Assert(repo.FullName).Equal("gordon/hello-world")
|
g.Assert(repo.FullName).Equal("gordon/hello-world")
|
||||||
g.Assert(repo.Link).Equal(hook.Repo.URL)
|
g.Assert(repo.Link).Equal(hook.Repo.HTMLURL)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should return a Perm struct from a Gitea Perm", func() {
|
g.It("Should return a Perm struct from a Gitea Perm", func() {
|
||||||
|
@ -69,7 +69,7 @@ func parsePushHook(payload io.Reader) (repo *model.Repo, build *model.Build, err
|
|||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = repoFromPush(push)
|
repo = toRepo(push.Repo)
|
||||||
build = buildFromPush(push)
|
build = buildFromPush(push)
|
||||||
return repo, build, err
|
return repo, build, err
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ func parseCreatedHook(payload io.Reader) (repo *model.Repo, build *model.Build,
|
|||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = repoFromPush(push)
|
repo = toRepo(push.Repo)
|
||||||
build = buildFromTag(push)
|
build = buildFromTag(push)
|
||||||
return repo, build, nil
|
return repo, build, nil
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ func parsePullRequestHook(payload io.Reader) (*model.Repo, *model.Build, error)
|
|||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = repoFromPullRequest(pr)
|
repo = toRepo(pr.Repo)
|
||||||
build = buildFromPullRequest(pr)
|
build = buildFromPullRequest(pr)
|
||||||
return repo, build, err
|
return repo, build, err
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,7 @@
|
|||||||
|
|
||||||
package gitea
|
package gitea
|
||||||
|
|
||||||
type commit struct {
|
import "code.gitea.io/sdk/gitea"
|
||||||
ID string `json:"id"`
|
|
||||||
Message string `json:"message"`
|
|
||||||
URL string `json:"url"`
|
|
||||||
Added []string `json:"added"`
|
|
||||||
Removed []string `json:"removed"`
|
|
||||||
Modified []string `json:"modified"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type pushHook struct {
|
type pushHook struct {
|
||||||
Sha string `json:"sha"`
|
Sha string `json:"sha"`
|
||||||
@ -31,117 +24,21 @@ type pushHook struct {
|
|||||||
Compare string `json:"compare_url"`
|
Compare string `json:"compare_url"`
|
||||||
RefType string `json:"ref_type"`
|
RefType string `json:"ref_type"`
|
||||||
|
|
||||||
Pusher struct {
|
Pusher *gitea.User `json:"pusher"`
|
||||||
Name string `json:"name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Login string `json:"login"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
} `json:"pusher"`
|
|
||||||
|
|
||||||
Repo struct {
|
Repo *gitea.Repository `json:"repository"`
|
||||||
ID int64 `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
FullName string `json:"full_name"`
|
|
||||||
URL string `json:"html_url"`
|
|
||||||
Private bool `json:"private"`
|
|
||||||
Owner struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
} `json:"owner"`
|
|
||||||
} `json:"repository"`
|
|
||||||
|
|
||||||
Commits []commit `json:"commits"`
|
Commits []gitea.PayloadCommit `json:"commits"`
|
||||||
|
|
||||||
HeadCommit commit `json:"head_commit"`
|
HeadCommit gitea.PayloadCommit `json:"head_commit"`
|
||||||
|
|
||||||
Sender struct {
|
Sender *gitea.User `json:"sender"`
|
||||||
ID int64 `json:"id"`
|
|
||||||
Login string `json:"login"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"sender"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type pullRequestHook struct {
|
type pullRequestHook struct {
|
||||||
Action string `json:"action"`
|
Action string `json:"action"`
|
||||||
Number int64 `json:"number"`
|
Number int64 `json:"number"`
|
||||||
PullRequest struct {
|
PullRequest *gitea.PullRequest `json:"pull_request"`
|
||||||
ID int64 `json:"id"`
|
Repo *gitea.Repository `json:"repository"`
|
||||||
User struct {
|
Sender *gitea.User `json:"sender"`
|
||||||
ID int64 `json:"id"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Name string `json:"full_name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"user"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
Body string `json:"body"`
|
|
||||||
State string `json:"state"`
|
|
||||||
URL string `json:"html_url"`
|
|
||||||
Mergeable bool `json:"mergeable"`
|
|
||||||
Merged bool `json:"merged"`
|
|
||||||
MergeBase string `json:"merge_base"`
|
|
||||||
Base struct {
|
|
||||||
Label string `json:"label"`
|
|
||||||
Ref string `json:"ref"`
|
|
||||||
Sha string `json:"sha"`
|
|
||||||
Repo struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
FullName string `json:"full_name"`
|
|
||||||
URL string `json:"html_url"`
|
|
||||||
Private bool `json:"private"`
|
|
||||||
Owner struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Name string `json:"full_name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"owner"`
|
|
||||||
} `json:"repo"`
|
|
||||||
} `json:"base"`
|
|
||||||
Head struct {
|
|
||||||
Label string `json:"label"`
|
|
||||||
Ref string `json:"ref"`
|
|
||||||
Sha string `json:"sha"`
|
|
||||||
Repo struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
FullName string `json:"full_name"`
|
|
||||||
URL string `json:"html_url"`
|
|
||||||
Private bool `json:"private"`
|
|
||||||
Owner struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Name string `json:"full_name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"owner"`
|
|
||||||
} `json:"repo"`
|
|
||||||
} `json:"head"`
|
|
||||||
} `json:"pull_request"`
|
|
||||||
Repo struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
FullName string `json:"full_name"`
|
|
||||||
URL string `json:"html_url"`
|
|
||||||
Private bool `json:"private"`
|
|
||||||
Owner struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Name string `json:"full_name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"owner"`
|
|
||||||
} `json:"repository"`
|
|
||||||
Sender struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Login string `json:"login"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Name string `json:"full_name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"sender"`
|
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ func (c *client) BranchHead(ctx context.Context, u *model.User, r *model.Repo, b
|
|||||||
// Hook parses the incoming Gogs hook and returns the Repository and Build
|
// Hook parses the incoming Gogs hook and returns the Repository and Build
|
||||||
// details. If the hook is unsupported nil values are returned.
|
// details. If the hook is unsupported nil values are returned.
|
||||||
func (c *client) Hook(ctx context.Context, r *http.Request) (*model.Repo, *model.Build, error) {
|
func (c *client) Hook(ctx context.Context, r *http.Request) (*model.Repo, *model.Build, error) {
|
||||||
return parseHook(r)
|
return parseHook(r, c.PrivateMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrgMembership returns if user is member of organization and if user
|
// OrgMembership returns if user is member of organization and if user
|
||||||
|
@ -34,10 +34,6 @@ func toRepo(from *gogs.Repository, privateMode bool) *model.Repo {
|
|||||||
from.HTMLURL,
|
from.HTMLURL,
|
||||||
from.Owner.AvatarUrl,
|
from.Owner.AvatarUrl,
|
||||||
)
|
)
|
||||||
private := from.Private
|
|
||||||
if privateMode {
|
|
||||||
private = true
|
|
||||||
}
|
|
||||||
return &model.Repo{
|
return &model.Repo{
|
||||||
RemoteID: model.RemoteID(fmt.Sprint(from.ID)),
|
RemoteID: model.RemoteID(fmt.Sprint(from.ID)),
|
||||||
SCMKind: model.RepoGit,
|
SCMKind: model.RepoGit,
|
||||||
@ -46,7 +42,7 @@ func toRepo(from *gogs.Repository, privateMode bool) *model.Repo {
|
|||||||
FullName: from.FullName,
|
FullName: from.FullName,
|
||||||
Avatar: avatar,
|
Avatar: avatar,
|
||||||
Link: from.HTMLURL,
|
Link: from.HTMLURL,
|
||||||
IsSCMPrivate: private,
|
IsSCMPrivate: from.Private || privateMode,
|
||||||
Clone: from.CloneURL,
|
Clone: from.CloneURL,
|
||||||
Branch: from.DefaultBranch,
|
Branch: from.DefaultBranch,
|
||||||
}
|
}
|
||||||
@ -72,14 +68,14 @@ func toTeam(from *gogs.Organization, link string) *model.Team {
|
|||||||
// helper function that extracts the Build data from a Gogs push hook
|
// helper function that extracts the Build data from a Gogs push hook
|
||||||
func buildFromPush(hook *pushHook) *model.Build {
|
func buildFromPush(hook *pushHook) *model.Build {
|
||||||
avatar := expandAvatar(
|
avatar := expandAvatar(
|
||||||
hook.Repo.URL,
|
hook.Repo.HTMLURL,
|
||||||
fixMalformedAvatar(hook.Sender.Avatar),
|
fixMalformedAvatar(hook.Sender.AvatarUrl),
|
||||||
)
|
)
|
||||||
author := hook.Sender.Login
|
author := hook.Sender.Login
|
||||||
if author == "" {
|
if author == "" {
|
||||||
author = hook.Sender.Username
|
author = hook.Sender.UserName
|
||||||
}
|
}
|
||||||
sender := hook.Sender.Username
|
sender := hook.Sender.UserName
|
||||||
if sender == "" {
|
if sender == "" {
|
||||||
sender = hook.Sender.Login
|
sender = hook.Sender.Login
|
||||||
}
|
}
|
||||||
@ -102,14 +98,14 @@ func buildFromPush(hook *pushHook) *model.Build {
|
|||||||
// helper function that extracts the Build data from a Gogs tag hook
|
// helper function that extracts the Build data from a Gogs tag hook
|
||||||
func buildFromTag(hook *pushHook) *model.Build {
|
func buildFromTag(hook *pushHook) *model.Build {
|
||||||
avatar := expandAvatar(
|
avatar := expandAvatar(
|
||||||
hook.Repo.URL,
|
hook.Repo.HTMLURL,
|
||||||
fixMalformedAvatar(hook.Sender.Avatar),
|
fixMalformedAvatar(hook.Sender.AvatarUrl),
|
||||||
)
|
)
|
||||||
author := hook.Sender.Login
|
author := hook.Sender.Login
|
||||||
if author == "" {
|
if author == "" {
|
||||||
author = hook.Sender.Username
|
author = hook.Sender.UserName
|
||||||
}
|
}
|
||||||
sender := hook.Sender.Username
|
sender := hook.Sender.UserName
|
||||||
if sender == "" {
|
if sender == "" {
|
||||||
sender = hook.Sender.Login
|
sender = hook.Sender.Login
|
||||||
}
|
}
|
||||||
@ -118,7 +114,7 @@ func buildFromTag(hook *pushHook) *model.Build {
|
|||||||
Event: model.EventTag,
|
Event: model.EventTag,
|
||||||
Commit: hook.After,
|
Commit: hook.After,
|
||||||
Ref: fmt.Sprintf("refs/tags/%s", hook.Ref),
|
Ref: fmt.Sprintf("refs/tags/%s", hook.Ref),
|
||||||
Link: fmt.Sprintf("%s/src/%s", hook.Repo.URL, hook.Ref),
|
Link: fmt.Sprintf("%s/src/%s", hook.Repo.HTMLURL, hook.Ref),
|
||||||
Branch: fmt.Sprintf("refs/tags/%s", hook.Ref),
|
Branch: fmt.Sprintf("refs/tags/%s", hook.Ref),
|
||||||
Message: fmt.Sprintf("created tag %s", hook.Ref),
|
Message: fmt.Sprintf("created tag %s", hook.Ref),
|
||||||
Avatar: avatar,
|
Avatar: avatar,
|
||||||
@ -131,10 +127,10 @@ func buildFromTag(hook *pushHook) *model.Build {
|
|||||||
// helper function that extracts the Build data from a Gogs pull_request hook
|
// helper function that extracts the Build data from a Gogs pull_request hook
|
||||||
func buildFromPullRequest(hook *pullRequestHook) *model.Build {
|
func buildFromPullRequest(hook *pullRequestHook) *model.Build {
|
||||||
avatar := expandAvatar(
|
avatar := expandAvatar(
|
||||||
hook.Repo.URL,
|
hook.Repo.HTMLURL,
|
||||||
fixMalformedAvatar(hook.PullRequest.User.Avatar),
|
fixMalformedAvatar(hook.PullRequest.User.AvatarUrl),
|
||||||
)
|
)
|
||||||
sender := hook.Sender.Username
|
sender := hook.Sender.UserName
|
||||||
if sender == "" {
|
if sender == "" {
|
||||||
sender = hook.Sender.Login
|
sender = hook.Sender.Login
|
||||||
}
|
}
|
||||||
@ -145,7 +141,7 @@ func buildFromPullRequest(hook *pullRequestHook) *model.Build {
|
|||||||
Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number),
|
Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number),
|
||||||
Branch: hook.PullRequest.BaseBranch,
|
Branch: hook.PullRequest.BaseBranch,
|
||||||
Message: hook.PullRequest.Title,
|
Message: hook.PullRequest.Title,
|
||||||
Author: hook.PullRequest.User.Username,
|
Author: hook.PullRequest.User.UserName,
|
||||||
Avatar: avatar,
|
Avatar: avatar,
|
||||||
Sender: sender,
|
Sender: sender,
|
||||||
Title: hook.PullRequest.Title,
|
Title: hook.PullRequest.Title,
|
||||||
@ -157,28 +153,6 @@ func buildFromPullRequest(hook *pullRequestHook) *model.Build {
|
|||||||
return build
|
return build
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function that extracts the Repository data from a Gogs push hook
|
|
||||||
func repoFromPush(hook *pushHook) *model.Repo {
|
|
||||||
return &model.Repo{
|
|
||||||
RemoteID: model.RemoteID(fmt.Sprint(hook.Repo.ID)),
|
|
||||||
Name: hook.Repo.Name,
|
|
||||||
Owner: hook.Repo.Owner.Username,
|
|
||||||
FullName: hook.Repo.FullName,
|
|
||||||
Link: hook.Repo.URL,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function that extracts the Repository data from a Gogs pull_request hook
|
|
||||||
func repoFromPullRequest(hook *pullRequestHook) *model.Repo {
|
|
||||||
return &model.Repo{
|
|
||||||
RemoteID: model.RemoteID(fmt.Sprint(hook.Repo.ID)),
|
|
||||||
Name: hook.Repo.Name,
|
|
||||||
Owner: hook.Repo.Owner.Username,
|
|
||||||
FullName: hook.Repo.FullName,
|
|
||||||
Link: hook.Repo.URL,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function that parses a push hook from a read closer.
|
// helper function that parses a push hook from a read closer.
|
||||||
func parsePush(r io.Reader) (*pushHook, error) {
|
func parsePush(r io.Reader) (*pushHook, error) {
|
||||||
push := new(pushHook)
|
push := new(pushHook)
|
||||||
|
@ -37,17 +37,15 @@ func Test_parse(t *testing.T) {
|
|||||||
g.Assert(hook.Before).Equal("4b2626259b5a97b6b4eab5e6cca66adb986b672b")
|
g.Assert(hook.Before).Equal("4b2626259b5a97b6b4eab5e6cca66adb986b672b")
|
||||||
g.Assert(hook.Compare).Equal("http://gogs.golang.org/gordon/hello-world/compare/4b2626259b5a97b6b4eab5e6cca66adb986b672b...ef98532add3b2feb7a137426bba1248724367df5")
|
g.Assert(hook.Compare).Equal("http://gogs.golang.org/gordon/hello-world/compare/4b2626259b5a97b6b4eab5e6cca66adb986b672b...ef98532add3b2feb7a137426bba1248724367df5")
|
||||||
g.Assert(hook.Repo.Name).Equal("hello-world")
|
g.Assert(hook.Repo.Name).Equal("hello-world")
|
||||||
g.Assert(hook.Repo.URL).Equal("http://gogs.golang.org/gordon/hello-world")
|
g.Assert(hook.Repo.HTMLURL).Equal("http://gogs.golang.org/gordon/hello-world")
|
||||||
g.Assert(hook.Repo.Owner.Name).Equal("gordon")
|
|
||||||
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
||||||
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
||||||
g.Assert(hook.Repo.Owner.Username).Equal("gordon")
|
g.Assert(hook.Repo.Owner.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Repo.Private).Equal(true)
|
g.Assert(hook.Repo.Private).Equal(true)
|
||||||
g.Assert(hook.Pusher.Name).Equal("gordon")
|
|
||||||
g.Assert(hook.Pusher.Email).Equal("gordon@golang.org")
|
g.Assert(hook.Pusher.Email).Equal("gordon@golang.org")
|
||||||
g.Assert(hook.Pusher.Username).Equal("gordon")
|
g.Assert(hook.Pusher.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Sender.Login).Equal("gordon")
|
g.Assert(hook.Sender.Login).Equal("gordon")
|
||||||
g.Assert(hook.Sender.Avatar).Equal("http://gogs.golang.org///1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
g.Assert(hook.Sender.AvatarUrl).Equal("http://gogs.golang.org///1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should parse tag hook payload", func() {
|
g.It("Should parse tag hook payload", func() {
|
||||||
@ -56,13 +54,13 @@ func Test_parse(t *testing.T) {
|
|||||||
g.Assert(err).IsNil()
|
g.Assert(err).IsNil()
|
||||||
g.Assert(hook.Ref).Equal("v1.0.0")
|
g.Assert(hook.Ref).Equal("v1.0.0")
|
||||||
g.Assert(hook.Repo.Name).Equal("hello-world")
|
g.Assert(hook.Repo.Name).Equal("hello-world")
|
||||||
g.Assert(hook.Repo.URL).Equal("http://gogs.golang.org/gordon/hello-world")
|
g.Assert(hook.Repo.HTMLURL).Equal("http://gogs.golang.org/gordon/hello-world")
|
||||||
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
||||||
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
||||||
g.Assert(hook.Repo.Owner.Username).Equal("gordon")
|
g.Assert(hook.Repo.Owner.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Repo.Private).Equal(true)
|
g.Assert(hook.Repo.Private).Equal(true)
|
||||||
g.Assert(hook.Sender.Username).Equal("gordon")
|
g.Assert(hook.Sender.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Sender.Avatar).Equal("https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
g.Assert(hook.Sender.AvatarUrl).Equal("https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should parse pull_request hook payload", func() {
|
g.It("Should parse pull_request hook payload", func() {
|
||||||
@ -73,18 +71,18 @@ func Test_parse(t *testing.T) {
|
|||||||
g.Assert(hook.Number).Equal(int64(1))
|
g.Assert(hook.Number).Equal(int64(1))
|
||||||
|
|
||||||
g.Assert(hook.Repo.Name).Equal("hello-world")
|
g.Assert(hook.Repo.Name).Equal("hello-world")
|
||||||
g.Assert(hook.Repo.URL).Equal("http://gogs.golang.org/gordon/hello-world")
|
g.Assert(hook.Repo.HTMLURL).Equal("http://gogs.golang.org/gordon/hello-world")
|
||||||
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
g.Assert(hook.Repo.FullName).Equal("gordon/hello-world")
|
||||||
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
g.Assert(hook.Repo.Owner.Email).Equal("gordon@golang.org")
|
||||||
g.Assert(hook.Repo.Owner.Username).Equal("gordon")
|
g.Assert(hook.Repo.Owner.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Repo.Private).Equal(true)
|
g.Assert(hook.Repo.Private).Equal(true)
|
||||||
g.Assert(hook.Sender.Username).Equal("gordon")
|
g.Assert(hook.Sender.UserName).Equal("gordon")
|
||||||
g.Assert(hook.Sender.Avatar).Equal("https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
g.Assert(hook.Sender.AvatarUrl).Equal("https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
|
|
||||||
g.Assert(hook.PullRequest.Title).Equal("Update the README with new information")
|
g.Assert(hook.PullRequest.Title).Equal("Update the README with new information")
|
||||||
g.Assert(hook.PullRequest.Body).Equal("please merge")
|
g.Assert(hook.PullRequest.Body).Equal("please merge")
|
||||||
g.Assert(hook.PullRequest.State).Equal("open")
|
g.Assert(hook.PullRequest.State).Equal("open")
|
||||||
g.Assert(hook.PullRequest.User.Username).Equal("gordon")
|
g.Assert(hook.PullRequest.User.UserName).Equal("gordon")
|
||||||
g.Assert(hook.PullRequest.Base.Label).Equal("master")
|
g.Assert(hook.PullRequest.Base.Label).Equal("master")
|
||||||
g.Assert(hook.PullRequest.Base.Ref).Equal("master")
|
g.Assert(hook.PullRequest.Base.Ref).Equal("master")
|
||||||
g.Assert(hook.PullRequest.Head.Label).Equal("feature/changes")
|
g.Assert(hook.PullRequest.Head.Label).Equal("feature/changes")
|
||||||
@ -108,11 +106,11 @@ func Test_parse(t *testing.T) {
|
|||||||
g.It("Should return a Repo struct from a push hook", func() {
|
g.It("Should return a Repo struct from a push hook", func() {
|
||||||
buf := bytes.NewBufferString(fixtures.HookPush)
|
buf := bytes.NewBufferString(fixtures.HookPush)
|
||||||
hook, _ := parsePush(buf)
|
hook, _ := parsePush(buf)
|
||||||
repo := repoFromPush(hook)
|
repo := toRepo(hook.Repo, false)
|
||||||
g.Assert(repo.Name).Equal(hook.Repo.Name)
|
g.Assert(repo.Name).Equal(hook.Repo.Name)
|
||||||
g.Assert(repo.Owner).Equal(hook.Repo.Owner.Username)
|
g.Assert(repo.Owner).Equal(hook.Repo.Owner.UserName)
|
||||||
g.Assert(repo.FullName).Equal("gordon/hello-world")
|
g.Assert(repo.FullName).Equal("gordon/hello-world")
|
||||||
g.Assert(repo.Link).Equal(hook.Repo.URL)
|
g.Assert(repo.Link).Equal(hook.Repo.HTMLURL)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should return a Build struct from a pull_request hook", func() {
|
g.It("Should return a Build struct from a pull_request hook", func() {
|
||||||
@ -126,17 +124,17 @@ func Test_parse(t *testing.T) {
|
|||||||
g.Assert(build.Branch).Equal("master")
|
g.Assert(build.Branch).Equal("master")
|
||||||
g.Assert(build.Message).Equal(hook.PullRequest.Title)
|
g.Assert(build.Message).Equal(hook.PullRequest.Title)
|
||||||
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
g.Assert(build.Author).Equal(hook.PullRequest.User.Username)
|
g.Assert(build.Author).Equal(hook.PullRequest.User.UserName)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should return a Repo struct from a pull_request hook", func() {
|
g.It("Should return a Repo struct from a pull_request hook", func() {
|
||||||
buf := bytes.NewBufferString(fixtures.HookPullRequest)
|
buf := bytes.NewBufferString(fixtures.HookPullRequest)
|
||||||
hook, _ := parsePullRequest(buf)
|
hook, _ := parsePullRequest(buf)
|
||||||
repo := repoFromPullRequest(hook)
|
repo := toRepo(hook.Repo, false)
|
||||||
g.Assert(repo.Name).Equal(hook.Repo.Name)
|
g.Assert(repo.Name).Equal(hook.Repo.Name)
|
||||||
g.Assert(repo.Owner).Equal(hook.Repo.Owner.Username)
|
g.Assert(repo.Owner).Equal(hook.Repo.Owner.UserName)
|
||||||
g.Assert(repo.FullName).Equal("gordon/hello-world")
|
g.Assert(repo.FullName).Equal("gordon/hello-world")
|
||||||
g.Assert(repo.Link).Equal(hook.Repo.URL)
|
g.Assert(repo.Link).Equal(hook.Repo.HTMLURL)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should return a Perm struct from a Gogs Perm", func() {
|
g.It("Should return a Perm struct from a Gogs Perm", func() {
|
||||||
|
@ -38,21 +38,21 @@ const (
|
|||||||
|
|
||||||
// parseHook parses a Bitbucket hook from an http.Request request and returns
|
// parseHook parses a Bitbucket hook from an http.Request request and returns
|
||||||
// Repo and Build detail. If a hook type is unsupported nil values are returned.
|
// Repo and Build detail. If a hook type is unsupported nil values are returned.
|
||||||
func parseHook(r *http.Request) (*model.Repo, *model.Build, error) {
|
func parseHook(r *http.Request, privateMode bool) (*model.Repo, *model.Build, error) {
|
||||||
switch r.Header.Get(hookEvent) {
|
switch r.Header.Get(hookEvent) {
|
||||||
case hookPush:
|
case hookPush:
|
||||||
return parsePushHook(r.Body)
|
return parsePushHook(r.Body, privateMode)
|
||||||
case hookCreated:
|
case hookCreated:
|
||||||
return parseCreatedHook(r.Body)
|
return parseCreatedHook(r.Body, privateMode)
|
||||||
case hookPullRequest:
|
case hookPullRequest:
|
||||||
return parsePullRequestHook(r.Body)
|
return parsePullRequestHook(r.Body, privateMode)
|
||||||
}
|
}
|
||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parsePushHook parses a push hook and returns the Repo and Build details.
|
// parsePushHook parses a push hook and returns the Repo and Build details.
|
||||||
// If the commit type is unsupported nil values are returned.
|
// If the commit type is unsupported nil values are returned.
|
||||||
func parsePushHook(payload io.Reader) (*model.Repo, *model.Build, error) {
|
func parsePushHook(payload io.Reader, privateMode bool) (*model.Repo, *model.Build, error) {
|
||||||
var (
|
var (
|
||||||
repo *model.Repo
|
repo *model.Repo
|
||||||
build *model.Build
|
build *model.Build
|
||||||
@ -68,14 +68,14 @@ func parsePushHook(payload io.Reader) (*model.Repo, *model.Build, error) {
|
|||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = repoFromPush(push)
|
repo = toRepo(push.Repo, privateMode)
|
||||||
build = buildFromPush(push)
|
build = buildFromPush(push)
|
||||||
return repo, build, err
|
return repo, build, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseCreatedHook parses a push hook and returns the Repo and Build details.
|
// parseCreatedHook parses a push hook and returns the Repo and Build details.
|
||||||
// If the commit type is unsupported nil values are returned.
|
// If the commit type is unsupported nil values are returned.
|
||||||
func parseCreatedHook(payload io.Reader) (*model.Repo, *model.Build, error) {
|
func parseCreatedHook(payload io.Reader, privateMode bool) (*model.Repo, *model.Build, error) {
|
||||||
var (
|
var (
|
||||||
repo *model.Repo
|
repo *model.Repo
|
||||||
build *model.Build
|
build *model.Build
|
||||||
@ -90,13 +90,13 @@ func parseCreatedHook(payload io.Reader) (*model.Repo, *model.Build, error) {
|
|||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = repoFromPush(push)
|
repo = toRepo(push.Repo, privateMode)
|
||||||
build = buildFromTag(push)
|
build = buildFromTag(push)
|
||||||
return repo, build, err
|
return repo, build, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// parsePullRequestHook parses a pull_request hook and returns the Repo and Build details.
|
// parsePullRequestHook parses a pull_request hook and returns the Repo and Build details.
|
||||||
func parsePullRequestHook(payload io.Reader) (*model.Repo, *model.Build, error) {
|
func parsePullRequestHook(payload io.Reader, privateMode bool) (*model.Repo, *model.Build, error) {
|
||||||
var (
|
var (
|
||||||
repo *model.Repo
|
repo *model.Repo
|
||||||
build *model.Build
|
build *model.Build
|
||||||
@ -115,7 +115,7 @@ func parsePullRequestHook(payload io.Reader) (*model.Repo, *model.Build, error)
|
|||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = repoFromPullRequest(pr)
|
repo = toRepo(pr.Repo, privateMode)
|
||||||
build = buildFromPullRequest(pr)
|
build = buildFromPullRequest(pr)
|
||||||
return repo, build, err
|
return repo, build, err
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package gogs
|
package gogs
|
||||||
|
|
||||||
|
import "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
type pushHook struct {
|
type pushHook struct {
|
||||||
Ref string `json:"ref"`
|
Ref string `json:"ref"`
|
||||||
Before string `json:"before"`
|
Before string `json:"before"`
|
||||||
@ -21,121 +23,43 @@ type pushHook struct {
|
|||||||
Compare string `json:"compare_url"`
|
Compare string `json:"compare_url"`
|
||||||
RefType string `json:"ref_type"`
|
RefType string `json:"ref_type"`
|
||||||
|
|
||||||
Pusher struct {
|
Pusher *gogs.User `json:"pusher"`
|
||||||
Name string `json:"name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Login string `json:"login"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
} `json:"pusher"`
|
|
||||||
|
|
||||||
Repo struct {
|
Repo *gogs.Repository `json:"repository"`
|
||||||
ID int64 `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
FullName string `json:"full_name"`
|
|
||||||
URL string `json:"html_url"`
|
|
||||||
Private bool `json:"private"`
|
|
||||||
Owner struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
} `json:"owner"`
|
|
||||||
} `json:"repository"`
|
|
||||||
|
|
||||||
Commits []struct {
|
Commits []gogs.PayloadCommit `json:"commits"`
|
||||||
ID string `json:"id"`
|
|
||||||
Message string `json:"message"`
|
|
||||||
URL string `json:"url"`
|
|
||||||
} `json:"commits"`
|
|
||||||
|
|
||||||
Sender struct {
|
Sender *gogs.User `json:"sender"`
|
||||||
ID int64 `json:"id"`
|
|
||||||
Login string `json:"login"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"sender"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type pullRequestHook struct {
|
type pullRequestHook struct {
|
||||||
Action string `json:"action"`
|
Action string `json:"action"`
|
||||||
Number int64 `json:"number"`
|
Number int64 `json:"number"`
|
||||||
PullRequest struct {
|
PullRequest struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
User struct {
|
User *gogs.User `json:"user"`
|
||||||
ID int64 `json:"id"`
|
Title string `json:"title"`
|
||||||
Username string `json:"username"`
|
Body string `json:"body"`
|
||||||
Name string `json:"full_name"`
|
State string `json:"state"`
|
||||||
Email string `json:"email"`
|
URL string `json:"html_url"`
|
||||||
Avatar string `json:"avatar_url"`
|
Mergeable bool `json:"mergeable"`
|
||||||
} `json:"user"`
|
Merged bool `json:"merged"`
|
||||||
Title string `json:"title"`
|
MergeBase string `json:"merge_base"`
|
||||||
Body string `json:"body"`
|
BaseBranch string `json:"base_branch"`
|
||||||
State string `json:"state"`
|
|
||||||
URL string `json:"html_url"`
|
|
||||||
Mergeable bool `json:"mergeable"`
|
|
||||||
Merged bool `json:"merged"`
|
|
||||||
MergeBase string `json:"merge_base"`
|
|
||||||
BaseBranch string `json:"base_branch"`
|
|
||||||
Base struct {
|
Base struct {
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
Ref string `json:"ref"`
|
Ref string `json:"ref"`
|
||||||
Sha string `json:"sha"`
|
Sha string `json:"sha"`
|
||||||
Repo struct {
|
Repo *gogs.Repository `json:"repo"`
|
||||||
ID int64 `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
FullName string `json:"full_name"`
|
|
||||||
URL string `json:"html_url"`
|
|
||||||
Private bool `json:"private"`
|
|
||||||
Owner struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Name string `json:"full_name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"owner"`
|
|
||||||
} `json:"repo"`
|
|
||||||
} `json:"base"`
|
} `json:"base"`
|
||||||
HeadBranch string `json:"head_branch"`
|
HeadBranch string `json:"head_branch"`
|
||||||
Head struct {
|
Head struct {
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
Ref string `json:"ref"`
|
Ref string `json:"ref"`
|
||||||
Sha string `json:"sha"`
|
Sha string `json:"sha"`
|
||||||
Repo struct {
|
Repo *gogs.Repository `json:"repo"`
|
||||||
ID int64 `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
FullName string `json:"full_name"`
|
|
||||||
URL string `json:"html_url"`
|
|
||||||
Private bool `json:"private"`
|
|
||||||
Owner struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Name string `json:"full_name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"owner"`
|
|
||||||
} `json:"repo"`
|
|
||||||
} `json:"head"`
|
} `json:"head"`
|
||||||
} `json:"pull_request"`
|
} `json:"pull_request"`
|
||||||
Repo struct {
|
Repo *gogs.Repository `json:"repository"`
|
||||||
ID int64 `json:"id"`
|
Sender *gogs.User `json:"sender"`
|
||||||
Name string `json:"name"`
|
|
||||||
FullName string `json:"full_name"`
|
|
||||||
URL string `json:"html_url"`
|
|
||||||
Private bool `json:"private"`
|
|
||||||
Owner struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Name string `json:"full_name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"owner"`
|
|
||||||
} `json:"repository"`
|
|
||||||
Sender struct {
|
|
||||||
ID int64 `json:"id"`
|
|
||||||
Login string `json:"login"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Name string `json:"full_name"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Avatar string `json:"avatar_url"`
|
|
||||||
} `json:"sender"`
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user