mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-09-26 13:40:06 +00:00
return nil when pull request comes from gitlab and add note
This commit is contained in:
parent
b516cb5782
commit
dc1ee4a5f9
1 changed files with 7 additions and 7 deletions
|
@ -213,14 +213,18 @@ func (r *Gitlab) Deactivate(user *common.User, repo *common.Repo, link string) e
|
||||||
|
|
||||||
// ParseHook parses the post-commit hook from the Request body
|
// ParseHook parses the post-commit hook from the Request body
|
||||||
// and returns the required data in a standard format.
|
// and returns the required data in a standard format.
|
||||||
// NOTE: in gitlab 8.0, gitlab will get same MR models as github
|
|
||||||
// https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/981/diffs
|
|
||||||
func (r *Gitlab) Hook(req *http.Request) (*common.Hook, error) {
|
func (r *Gitlab) Hook(req *http.Request) (*common.Hook, error) {
|
||||||
|
|
||||||
var payload, _ = ioutil.ReadAll(req.Body)
|
var payload, _ = ioutil.ReadAll(req.Body)
|
||||||
var parsed, _ = gogitlab.ParseHook(payload)
|
var parsed, _ = gogitlab.ParseHook(payload)
|
||||||
obj := parsed.ObjectAttributes
|
|
||||||
|
|
||||||
|
if parsed.ObjectKind == "merge_request" {
|
||||||
|
// NOTE: in gitlab 8.0, gitlab will get same MR models as github
|
||||||
|
// https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/981/diffs
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
obj := parsed.ObjectAttributes
|
||||||
if !(obj.State == "opened" && obj.MergeStatus == "unchecked") {
|
if !(obj.State == "opened" && obj.MergeStatus == "unchecked") {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -238,15 +242,11 @@ func (r *Gitlab) Hook(req *http.Request) (*common.Hook, error) {
|
||||||
if obj.Source.Name != obj.Target.Name || obj.Source.Namespace != obj.Target.Namespace {
|
if obj.Source.Name != obj.Target.Name || obj.Source.Namespace != obj.Target.Namespace {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//hook.SourceRemote = obj.Source.HttpUrl
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hook.Commit.Author.Login = req.FormValue("owner")
|
hook.Commit.Author.Login = req.FormValue("owner")
|
||||||
//hook.Repo = req.FormValue("name")
|
|
||||||
hook.Commit.Sha = obj.LastCommit.Id
|
hook.Commit.Sha = obj.LastCommit.Id
|
||||||
hook.Commit.Branch = obj.TargetBranch
|
hook.Commit.Branch = obj.TargetBranch
|
||||||
//hook.Commit.SourceBranch = obj.SourceBranch
|
|
||||||
hook.Commit.Timestamp = obj.LastCommit.Timestamp
|
hook.Commit.Timestamp = obj.LastCommit.Timestamp
|
||||||
hook.Commit.Message = obj.Title
|
hook.Commit.Message = obj.Title
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue