Skip to content

Commit 2d24da0

Browse files
committed
clean up labelsMatch() func
1 parent 6541b0a commit 2d24da0

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

internal/cmd/match_criteria.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,26 @@ func labelsMatch(prLabels, ignoreLabels, selectLabels []string) bool {
6666
}
6767

6868
// If the pull request contains any of the ignore labels, it doesn't match
69-
if len(ignoreLabels) > 0 && len(prLabels) > 0 {
70-
for _, l := range ignoreLabels {
71-
if i := slices.Index(prLabels, l); i != -1 {
72-
return false
73-
}
69+
for _, l := range ignoreLabels {
70+
if slices.Contains(prLabels, l) {
71+
return false
7472
}
7573
}
7674

77-
// If ignoreLabels are specified without selectLabels and the pull request has no labels, it matches
78-
if len(ignoreLabels) > 0 && len(selectLabels) == 0 && len(prLabels) == 0 {
79-
return true
80-
}
81-
8275
// If selectLabels are specified but the pull request has no labels, it doesn't match
8376
if len(selectLabels) > 0 && len(prLabels) == 0 {
8477
return false
8578
}
8679

8780
// If the pull request contains any of the select labels, it matches
88-
if len(selectLabels) > 0 && len(prLabels) > 0 {
89-
for _, l := range selectLabels {
90-
if i := slices.Index(prLabels, l); i != -1 {
91-
return true
92-
}
81+
for _, l := range selectLabels {
82+
if slices.Contains(prLabels, l) {
83+
return true
9384
}
94-
// If none of the select labels are found, it doesn't match
95-
return false
9685
}
9786

98-
return true
87+
// If none of the select labels are found, it doesn't match
88+
return len(selectLabels) == 0
9989
}
10090

10191
// GraphQL response structure for PR status info

0 commit comments

Comments
 (0)