-
Notifications
You must be signed in to change notification settings - Fork 0
/
issues.go
57 lines (49 loc) · 1.07 KB
/
issues.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
54
55
56
57
package gittt
import (
"encoding/json"
"log"
)
type Issue struct {
Info IssueInfo
}
type IssueInfo struct {
State string `json:"state"`
Title string `json:"title"`
Body string `json:"body"`
Labels []Label `json:"labels"`
}
func IssuesTrigger(g *Gittt, data []byte) error {
var i Issue
err := json.Unmarshal(data, &i)
if err != nil {
return err
}
log.Println("Issue Event Received")
actions := g.matchConditionals(IssuesEvent, i)
for _, action := range actions {
action.Do(i)
}
return nil
}
func (g *Gittt) IssueLabelsIsOneOf(data interface{}, labels ...interface{}) bool {
if i, ok := data.(Issue); ok {
for _, label := range labels {
for _, l := range i.Info.Labels {
if label.(string) == l.Name {
log.Printf("Condition match: labels contains %s\n", label.(string))
return true
}
}
}
}
return false
}
func (g *Gittt) IssueIsClosed(data interface{}, _ ...interface{}) bool {
if i, ok := data.(Issue); ok {
if i.Info.State == "closed" {
log.Println("Condition match: Issue is closed.")
return true
}
}
return false
}