@@ -60,21 +60,39 @@ func branchMatchesCriteria(branch string) bool {
60
60
}
61
61
62
62
func labelsMatch (prLabels , ignoreLabels , selectLabels []string ) bool {
63
- for _ , l := range ignoreLabels {
64
- if i := slices .Index (prLabels , l ); i != - 1 {
65
- return false
66
- }
63
+ // If no ignoreLabels or selectLabels are specified, all labels pass this check
64
+ if len (ignoreLabels ) == 0 && len (selectLabels ) == 0 {
65
+ return true
67
66
}
68
67
69
- for _ , l := range selectLabels {
70
- found := false
71
- if i := slices .Index (prLabels , l ); i != - 1 {
72
- break
68
+ // 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
+ }
73
74
}
75
+ }
74
76
75
- if ! found {
76
- return false
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
+
82
+ // If selectLabels are specified but the pull request has no labels, it doesn't match
83
+ if len (selectLabels ) > 0 && len (prLabels ) == 0 {
84
+ return false
85
+ }
86
+
87
+ // 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
+ }
77
93
}
94
+ // If none of the select labels are found, it doesn't match
95
+ return false
78
96
}
79
97
80
98
return true
0 commit comments