@@ -156,6 +156,7 @@ type PayloadCommitVerification struct {
156
156
157
157
var (
158
158
_ Payloader = & CreatePayload {}
159
+ _ Payloader = & DeletePayload {}
159
160
_ Payloader = & PushPayload {}
160
161
_ Payloader = & IssuePayload {}
161
162
_ Payloader = & PullRequestPayload {}
@@ -208,6 +209,53 @@ func ParseCreateHook(raw []byte) (*CreatePayload, error) {
208
209
return hook , nil
209
210
}
210
211
212
+ // ________ .__ __
213
+ // \______ \ ____ | | _____/ |_ ____
214
+ // | | \_/ __ \| | _/ __ \ __\/ __ \
215
+ // | ` \ ___/| |_\ ___/| | \ ___/
216
+ // /_______ /\___ >____/\___ >__| \___ >
217
+ // \/ \/ \/ \/
218
+
219
+ type PusherType string
220
+
221
+ const (
222
+ PUSHER_TYPE_USER PusherType = "user"
223
+ )
224
+
225
+ type DeletePayload struct {
226
+ Secret string `json:"secret"`
227
+ Ref string `json:"ref"`
228
+ RefType string `json:"ref_type"`
229
+ PusherType PusherType `json:"pusher_type"`
230
+ Repo * Repository `json:"repository"`
231
+ Sender * User `json:"sender"`
232
+ }
233
+
234
+ // SetSecret FIXME
235
+ func (p * DeletePayload ) SetSecret (secret string ) {
236
+ p .Secret = secret
237
+ }
238
+
239
+ func (p * DeletePayload ) JSONPayload () ([]byte , error ) {
240
+ return json .MarshalIndent (p , "" , " " )
241
+ }
242
+
243
+ // ParseDeleteHook parses push event hook content.
244
+ func ParseDeleteHook (raw []byte ) (* DeletePayload , error ) {
245
+ hook := new (DeletePayload )
246
+ if err := json .Unmarshal (raw , hook ); err != nil {
247
+ return nil , err
248
+ }
249
+
250
+ switch {
251
+ case hook .Repo == nil :
252
+ return nil , ErrInvalidReceiveHook
253
+ case len (hook .Ref ) == 0 :
254
+ return nil , ErrInvalidReceiveHook
255
+ }
256
+ return hook , nil
257
+ }
258
+
211
259
// __________ .__
212
260
// \______ \__ __ _____| |__
213
261
// | ___/ | \/ ___/ | \
0 commit comments