mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-27 01:30:46 +00:00
Added support for new attributes
This commit is contained in:
parent
19a7ae53e6
commit
39dc9f7c76
|
@ -63,12 +63,17 @@ type Person struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type hProject struct {
|
type hProject struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
SshUrl string `json:"ssh_url"`
|
SshUrl string `json:"ssh_url"`
|
||||||
HttpUrl string `json:"http_url"`
|
HttpUrl string `json:"http_url"`
|
||||||
VisibilityLevel int `json:"visibility_level"`
|
GitSshUrl string `json:"git_ssh_url"`
|
||||||
WebUrl string `json:"web_url"`
|
GitHttpUrl string `json:"git_http_url"`
|
||||||
Namespace string `json:"namespace"`
|
AvatarUrl string `json:"avatar_url"`
|
||||||
|
VisibilityLevel int `json:"visibility_level"`
|
||||||
|
WebUrl string `json:"web_url"`
|
||||||
|
PathWithNamespace string `json:"path_with_namespace"`
|
||||||
|
DefaultBranch string `json:"default_branch"`
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type hRepository struct {
|
type hRepository struct {
|
||||||
|
@ -123,6 +128,7 @@ type HookPayload struct {
|
||||||
UserId int `json:"user_id,omitempty"`
|
UserId int `json:"user_id,omitempty"`
|
||||||
UserName string `json:"user_name,omitempty"`
|
UserName string `json:"user_name,omitempty"`
|
||||||
ProjectId int `json:"project_id,omitempty"`
|
ProjectId int `json:"project_id,omitempty"`
|
||||||
|
Project *hProject `json:"project,omitempty"`
|
||||||
Repository *hRepository `json:"repository,omitempty"`
|
Repository *hRepository `json:"repository,omitempty"`
|
||||||
Commits []hCommit `json:"commits,omitempty"`
|
Commits []hCommit `json:"commits,omitempty"`
|
||||||
TotalCommitsCount int `json:"total_commits_count,omitempty"`
|
TotalCommitsCount int `json:"total_commits_count,omitempty"`
|
||||||
|
|
|
@ -383,27 +383,45 @@ func mergeRequest(parsed *client.HookPayload, req *http.Request) (*model.Repo, *
|
||||||
}
|
}
|
||||||
|
|
||||||
func push(parsed *client.HookPayload, req *http.Request) (*model.Repo, *model.Build, error) {
|
func push(parsed *client.HookPayload, req *http.Request) (*model.Repo, *model.Build, error) {
|
||||||
var cloneUrl = parsed.Repository.GitHttpUrl
|
|
||||||
|
|
||||||
repo := &model.Repo{}
|
repo := &model.Repo{}
|
||||||
repo.Owner = req.FormValue("owner")
|
repo.Owner = req.FormValue("owner")
|
||||||
repo.Name = req.FormValue("name")
|
repo.Name = req.FormValue("name")
|
||||||
repo.FullName = fmt.Sprintf("%s/%s", repo.Owner, repo.Name)
|
|
||||||
repo.Link = parsed.Repository.URL
|
|
||||||
repo.Clone = cloneUrl
|
|
||||||
repo.Branch = "master"
|
|
||||||
|
|
||||||
switch parsed.Repository.VisibilityLevel {
|
// Since gitlab 8.5, used project instead repository key
|
||||||
case 0:
|
// see https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/web_hooks/web_hooks.md#web-hooks
|
||||||
repo.IsPrivate = true
|
if project := parsed.Project; project != nil {
|
||||||
case 10:
|
repo.Avatar = project.AvatarUrl
|
||||||
repo.IsPrivate = true
|
repo.Link = project.WebUrl
|
||||||
case 20:
|
repo.Clone = project.GitHttpUrl
|
||||||
repo.IsPrivate = false
|
repo.FullName = project.PathWithNamespace
|
||||||
|
repo.Branch = project.DefaultBranch
|
||||||
|
|
||||||
|
switch project.VisibilityLevel {
|
||||||
|
case 0:
|
||||||
|
repo.IsPrivate = true
|
||||||
|
case 10:
|
||||||
|
repo.IsPrivate = true
|
||||||
|
case 20:
|
||||||
|
repo.IsPrivate = false
|
||||||
|
}
|
||||||
|
} else if repository := parsed.Repository; repository != nil {
|
||||||
|
repo.Link = repository.URL
|
||||||
|
repo.Clone = repository.GitHttpUrl
|
||||||
|
repo.Branch = "master"
|
||||||
|
repo.FullName = fmt.Sprintf("%s/%s", req.FormValue("owner"), req.FormValue("name"))
|
||||||
|
|
||||||
|
switch repository.VisibilityLevel {
|
||||||
|
case 0:
|
||||||
|
repo.IsPrivate = true
|
||||||
|
case 10:
|
||||||
|
repo.IsPrivate = true
|
||||||
|
case 20:
|
||||||
|
repo.IsPrivate = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, nil, fmt.Errorf("No project/repository keys given")
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.FullName = fmt.Sprintf("%s/%s", req.FormValue("owner"), req.FormValue("name"))
|
|
||||||
|
|
||||||
build := &model.Build{}
|
build := &model.Build{}
|
||||||
build.Event = model.EventPush
|
build.Event = model.EventPush
|
||||||
build.Commit = parsed.After
|
build.Commit = parsed.After
|
||||||
|
|
Loading…
Reference in a new issue