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