-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitbucket.go
53 lines (43 loc) · 1.19 KB
/
bitbucket.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"strings"
log "github.com/sirupsen/logrus"
)
type bitbucketPayload struct {
// Push
Push bitbucketPush `json:"push"`
// Repository
Repository bitbucketRepository `json:"repository"`
}
// Push is the common Bitbucket Push Sub Entity
type bitbucketPush struct {
Changes []bitbucketChange `json:"changes"`
}
// Change is the common Bitbucket Change Sub Entity
type bitbucketChange struct {
New bitbucketChangeData `json:"new"`
}
// ChangeData is the common Bitbucket ChangeData Sub Entity
type bitbucketChangeData struct {
Name string `json:"name"`
}
// Repository is the common Bitbucket Repository Entity
type bitbucketRepository struct {
Links bitbucketLinks `json:"links"`
}
// Links is the common Bitbucket Links Sub Entity
type bitbucketLinks struct {
HTML bitbucketHTML `json:"html"`
}
// HTML is the common Bitbucket HTML Sub Entity
type bitbucketHTML struct {
HREF string `json:"href"`
}
func init() {
var payload bitbucketPayload
route("/bitbucket", &payload, func(hook Hook) bool {
log.Info(payload.Push.Changes[0].New.Name)
return strings.TrimRight(hook.Repo, "/") == payload.Repository.Links.HTML.HREF &&
payload.Push.Changes[0].New.Name == hook.Branch
})
}