-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.go
57 lines (50 loc) · 1016 Bytes
/
utils.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 main
import "strings"
func deleteZero(group map[string][]*PullRequest) {
for name, conflicts := range group {
if len(conflicts) == 0 {
delete(group, name)
}
}
}
func deleteSingle(group map[string][]*PullRequest) {
for name, conflicts := range group {
if len(conflicts) == 1 {
delete(group, name)
}
}
}
func containsString(xs []string, needle string) bool {
for _, x := range xs {
if strings.EqualFold(x, needle) {
return true
}
}
return false
}
func containsAnyString(xs []string, needles []string) bool {
for _, x := range xs {
for _, needle := range needles {
if strings.EqualFold(x, needle) {
return true
}
}
}
return false
}
func hasAnyPrefix(path string, prefixes []string) bool {
for _, prefix := range prefixes {
if strings.HasPrefix(path, prefix) {
return true
}
}
return false
}
func containsPR(prs []*PullRequest, pullRequest *PullRequest) bool {
for _, pr := range prs {
if pr == pullRequest {
return true
}
}
return false
}