mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
Fix Gitea remote pull-request webhook parsing
This commit is contained in:
parent
75150d4a42
commit
e4a77e5346
4 changed files with 14 additions and 17 deletions
|
@ -103,13 +103,11 @@ const HookPullRequest = `{
|
||||||
"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"
|
||||||
},
|
},
|
||||||
"base_branch": "master",
|
|
||||||
"base": {
|
"base": {
|
||||||
"label": "master",
|
"label": "master",
|
||||||
"ref": "master",
|
"ref": "master",
|
||||||
"sha": "9353195a19e45482665306e466c832c46560532d"
|
"sha": "9353195a19e45482665306e466c832c46560532d"
|
||||||
},
|
},
|
||||||
"head_branch": "feature/changes",
|
|
||||||
"head": {
|
"head": {
|
||||||
"label": "feature/changes",
|
"label": "feature/changes",
|
||||||
"ref": "feature/changes",
|
"ref": "feature/changes",
|
||||||
|
|
|
@ -127,15 +127,15 @@ func buildFromPullRequest(hook *pullRequestHook) *model.Build {
|
||||||
Commit: hook.PullRequest.Head.Sha,
|
Commit: hook.PullRequest.Head.Sha,
|
||||||
Link: hook.PullRequest.URL,
|
Link: hook.PullRequest.URL,
|
||||||
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.Base.Ref,
|
||||||
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,
|
||||||
Refspec: fmt.Sprintf("%s:%s",
|
Refspec: fmt.Sprintf("%s:%s",
|
||||||
hook.PullRequest.HeadBranch,
|
hook.PullRequest.Head.Ref,
|
||||||
hook.PullRequest.BaseBranch,
|
hook.PullRequest.Base.Ref,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
return build
|
return build
|
||||||
|
|
|
@ -127,6 +127,7 @@ func Test_parse(t *testing.T) {
|
||||||
g.Assert(build.Ref).Equal("refs/pull/1/head")
|
g.Assert(build.Ref).Equal("refs/pull/1/head")
|
||||||
g.Assert(build.Link).Equal(hook.PullRequest.URL)
|
g.Assert(build.Link).Equal(hook.PullRequest.URL)
|
||||||
g.Assert(build.Branch).Equal("master")
|
g.Assert(build.Branch).Equal("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.User.Username)
|
||||||
|
|
|
@ -62,7 +62,6 @@ type pullRequestHook struct {
|
||||||
Mergeable bool `json:"mergeable"`
|
Mergeable bool `json:"mergeable"`
|
||||||
Merged bool `json:"merged"`
|
Merged bool `json:"merged"`
|
||||||
MergeBase string `json:"merge_base"`
|
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"`
|
||||||
|
@ -82,7 +81,6 @@ type pullRequestHook struct {
|
||||||
} `json:"owner"`
|
} `json:"owner"`
|
||||||
} `json:"repo"`
|
} `json:"repo"`
|
||||||
} `json:"base"`
|
} `json:"base"`
|
||||||
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"`
|
||||||
|
|
Loading…
Reference in a new issue