webhook: able to detect delete branch or tag (#2315)

This commit is contained in:
Unknwon
2017-02-24 15:35:20 -05:00
parent 7fe13e72d8
commit f0086e66ae
13 changed files with 207 additions and 87 deletions

View File

@@ -91,6 +91,7 @@ type PayloadCommit struct {
var (
_ Payloader = &CreatePayload{}
_ Payloader = &DeletePayload{}
_ Payloader = &PushPayload{}
_ Payloader = &PullRequestPayload{}
)
@@ -103,10 +104,11 @@ var (
// \/ \/ \/ \/
type CreatePayload struct {
Ref string `json:"ref"`
RefType string `json:"ref_type"`
Repo *Repository `json:"repository"`
Sender *User `json:"sender"`
Ref string `json:"ref"`
RefType string `json:"ref_type"`
DefaultBranch string `json:"default_branch"`
Repo *Repository `json:"repository"`
Sender *User `json:"sender"`
}
func (p *CreatePayload) JSONPayload() ([]byte, error) {
@@ -133,6 +135,31 @@ func ParseCreateHook(raw []byte) (*CreatePayload, error) {
return hook, nil
}
// ________ .__ __
// \______ \ ____ | | _____/ |_ ____
// | | \_/ __ \| | _/ __ \ __\/ __ \
// | ` \ ___/| |_\ ___/| | \ ___/
// /_______ /\___ >____/\___ >__| \___ >
// \/ \/ \/ \/
type PusherType string
const (
PUSHER_TYPE_USER PusherType = "user"
)
type DeletePayload struct {
Ref string `json:"ref"`
RefType string `json:"ref_type"`
PusherType PusherType `json:"pusher_type"`
Repo *Repository `json:"repository"`
Sender *User `json:"sender"`
}
func (p *DeletePayload) JSONPayload() ([]byte, error) {
return json.MarshalIndent(p, "", " ")
}
// __________ .__
// \______ \__ __ _____| |__
// | ___/ | \/ ___/ | \