fix: utils/hook webhook
This commit is contained in:
parent
6dd4ff2c87
commit
9c568c2a59
|
@ -156,6 +156,8 @@ type Repository struct {
|
||||||
OriginalURL string `xorm:"VARCHAR(2048)"`
|
OriginalURL string `xorm:"VARCHAR(2048)"`
|
||||||
DefaultBranch string
|
DefaultBranch string
|
||||||
|
|
||||||
|
NumWikis int
|
||||||
|
|
||||||
NumWatches int
|
NumWatches int
|
||||||
NumStars int
|
NumStars int
|
||||||
NumForks int
|
NumForks int
|
||||||
|
@ -181,6 +183,10 @@ type Repository struct {
|
||||||
Units []*RepoUnit `xorm:"-"`
|
Units []*RepoUnit `xorm:"-"`
|
||||||
PrimaryLanguage *LanguageStat `xorm:"-"`
|
PrimaryLanguage *LanguageStat `xorm:"-"`
|
||||||
|
|
||||||
|
|
||||||
|
IsWiki bool `xorm:"INDEX NOT NULL DEFAULT false"`
|
||||||
|
WikiID int64 `xorm:"INDEX"`
|
||||||
|
|
||||||
IsFork bool `xorm:"INDEX NOT NULL DEFAULT false"`
|
IsFork bool `xorm:"INDEX NOT NULL DEFAULT false"`
|
||||||
ForkID int64 `xorm:"INDEX"`
|
ForkID int64 `xorm:"INDEX"`
|
||||||
BaseRepo *Repository `xorm:"-"`
|
BaseRepo *Repository `xorm:"-"`
|
||||||
|
@ -2119,6 +2125,18 @@ func CopyLFS(ctx DBContext, newRepo, oldRepo *Repository) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
/////////////////////////////GetWiki
|
||||||
|
func (repo *Repository) GetWikis(listOptions ListOptions) ([]*Repository, error) {
|
||||||
|
if listOptions.Page == 0 {
|
||||||
|
wikis := make([]*Repository, 0, repo.NumWikis)
|
||||||
|
return wikis, x.Find(&wikis, &Repository{WikiID: repo.ID})
|
||||||
|
}
|
||||||
|
|
||||||
|
sess := listOptions.getPaginatedSession()
|
||||||
|
wikis := make([]*Repository, 0, listOptions.PageSize)
|
||||||
|
return wikis, sess.Find(&wikis, &Repository{WikiID: repo.ID})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetForks returns all the forks of the repository
|
// GetForks returns all the forks of the repository
|
||||||
func (repo *Repository) GetForks(listOptions ListOptions) ([]*Repository, error) {
|
func (repo *Repository) GetForks(listOptions ListOptions) ([]*Repository, error) {
|
||||||
|
|
|
@ -83,6 +83,7 @@ type HookEvent struct {
|
||||||
SendEverything bool `json:"send_everything"`
|
SendEverything bool `json:"send_everything"`
|
||||||
ChooseEvents bool `json:"choose_events"`
|
ChooseEvents bool `json:"choose_events"`
|
||||||
BranchFilter string `json:"branch_filter"`
|
BranchFilter string `json:"branch_filter"`
|
||||||
|
HTTPMethod string `json:"http_method"`
|
||||||
|
|
||||||
HookEvents `json:"events"`
|
HookEvents `json:"events"`
|
||||||
}
|
}
|
||||||
|
@ -115,6 +116,7 @@ type Webhook struct {
|
||||||
HookTaskType HookTaskType
|
HookTaskType HookTaskType
|
||||||
Meta string `xorm:"TEXT"` // store hook-specific attributes
|
Meta string `xorm:"TEXT"` // store hook-specific attributes
|
||||||
LastStatus HookStatus // Last delivery status
|
LastStatus HookStatus // Last delivery status
|
||||||
|
BranchFilter string `xorm:"TEXT"`
|
||||||
|
|
||||||
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
|
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
|
||||||
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
|
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
|
||||||
|
|
|
@ -268,11 +268,13 @@ func ToHook(repoLink string, w *models.Webhook) *api.Hook {
|
||||||
ID: w.ID,
|
ID: w.ID,
|
||||||
Type: w.HookTaskType.Name(),
|
Type: w.HookTaskType.Name(),
|
||||||
URL: fmt.Sprintf("%s/settings/hooks/%d", repoLink, w.ID),
|
URL: fmt.Sprintf("%s/settings/hooks/%d", repoLink, w.ID),
|
||||||
|
BranchFilter:w.HookEvent.BranchFilter,
|
||||||
Active: w.IsActive,
|
Active: w.IsActive,
|
||||||
Config: config,
|
Config: config,
|
||||||
Events: w.EventsArray(),
|
Events: w.EventsArray(),
|
||||||
Updated: w.UpdatedUnix.AsTime(),
|
Updated: w.UpdatedUnix.AsTime(),
|
||||||
Created: w.CreatedUnix.AsTime(),
|
Created: w.CreatedUnix.AsTime(),
|
||||||
|
HTTPMethod: w.HookEvent.HTTPMethod,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ type Hook struct {
|
||||||
Config map[string]string `json:"config"`
|
Config map[string]string `json:"config"`
|
||||||
Events []string `json:"events"`
|
Events []string `json:"events"`
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
|
BranchFilter string `json:"branch_filter"`
|
||||||
|
HTTPMethod string `json:"http_method"`
|
||||||
// swagger:strfmt date-time
|
// swagger:strfmt date-time
|
||||||
Updated time.Time `json:"updated_at"`
|
Updated time.Time `json:"updated_at"`
|
||||||
// swagger:strfmt date-time
|
// swagger:strfmt date-time
|
||||||
|
|
|
@ -101,13 +101,14 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID
|
||||||
if len(form.Events) == 0 {
|
if len(form.Events) == 0 {
|
||||||
form.Events = []string{"push"}
|
form.Events = []string{"push"}
|
||||||
}
|
}
|
||||||
|
|
||||||
w := &models.Webhook{
|
w := &models.Webhook{
|
||||||
OrgID: orgID,
|
OrgID: orgID,
|
||||||
RepoID: repoID,
|
RepoID: repoID,
|
||||||
URL: form.Config["url"],
|
URL: form.Config["url"],
|
||||||
ContentType: models.ToHookContentType(form.Config["content_type"]),
|
ContentType: models.ToHookContentType(form.Config["content_type"]),
|
||||||
Secret: form.Config["secret"],
|
Secret: form.Config["secret"],
|
||||||
HTTPMethod: "POST",
|
HTTPMethod: form.Config["http_method"],
|
||||||
HookEvent: &models.HookEvent{
|
HookEvent: &models.HookEvent{
|
||||||
ChooseEvents: true,
|
ChooseEvents: true,
|
||||||
HookEvents: models.HookEvents{
|
HookEvents: models.HookEvents{
|
||||||
|
|
|
@ -13348,6 +13348,10 @@
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"x-go-name": "Active"
|
"x-go-name": "Active"
|
||||||
},
|
},
|
||||||
|
"branch_filter": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "BranchFilter"
|
||||||
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
|
@ -13367,6 +13371,10 @@
|
||||||
},
|
},
|
||||||
"x-go-name": "Events"
|
"x-go-name": "Events"
|
||||||
},
|
},
|
||||||
|
"http_method": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "HTTPMethod"
|
||||||
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int64",
|
"format": "int64",
|
||||||
|
|
Loading…
Reference in New Issue