/
tools.go
50 lines (44 loc) · 1.18 KB
/
tools.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
package gh
import (
"poule/configuration"
"github.com/google/go-github/github"
)
// HasLabel returns true if a collection of labels contains the specified label.
func HasLabel(label string, issueLabels []github.Label) bool {
for _, issueLabel := range issueLabels {
if label == *issueLabel.Name {
return true
}
}
return false
}
// HasAnyLabels returns true if a collection of labels contains any of the specified collection of
// labels.
func HasAnyLabels(labels []string, issueLabels []github.Label) bool {
for _, label := range labels {
if HasLabel(label, issueLabels) {
return true
}
}
return false
}
// HasAllLabels returns true if a collection of labels contains all of the specified collection of
// labels.
func HasAllLabels(labels []string, issueLabels []github.Label) bool {
for _, label := range labels {
if !HasLabel(label, issueLabels) {
return false
}
}
return true
}
// HasFailingCILabel returns true if a collection of labels contains the particular label indicating
// test failures.
func HasFailingCILabel(labels []github.Label) bool {
for _, l := range labels {
if *l.Name == configuration.FailingCILabel {
return true
}
}
return false
}