@@ -35,22 +35,35 @@ impl Handler for PrioritizeHandler {
35
35
if let Event :: Issue ( e) = event {
36
36
if e. action == github:: IssuesAction :: Labeled {
37
37
if let Some ( config) = config {
38
- if e. label . as_ref ( ) . expect ( "label" ) . name == config. label {
38
+ let label_name = & e. label . as_ref ( ) . expect ( "label" ) . name ;
39
+
40
+ if * label_name == config. label {
39
41
// We need to take the exact same action in this case.
40
42
return Ok ( Some ( Prioritize :: Start ) ) ;
41
43
} else {
42
- match glob:: Pattern :: new ( & config. priority_labels ) {
43
- Ok ( glob) => {
44
- let issue_labels = event. issue ( ) . unwrap ( ) . labels ( ) ;
45
- let label_name = & e. label . as_ref ( ) . expect ( "label" ) . name ;
46
-
47
- if issue_labels. iter ( ) . all ( |l| !glob. matches ( & l. name ) )
48
- && config. prioritize_on . iter ( ) . any ( |l| l == label_name)
49
- {
50
- return Ok ( Some ( Prioritize :: Label ) ) ;
44
+ if config. prioritize_on . iter ( ) . any ( |l| l == label_name) {
45
+ let mut prioritize = false ;
46
+
47
+ for label in event. issue ( ) . unwrap ( ) . labels ( ) {
48
+ for exclude_label in & config. exclude_labels {
49
+ match glob:: Pattern :: new ( exclude_label) {
50
+ Ok ( exclude_glob) => {
51
+ prioritize = !exclude_glob. matches ( & label. name ) ;
52
+ }
53
+ Err ( error) => {
54
+ log:: error!( "Invalid glob pattern: {}" , error) ;
55
+ }
56
+ }
57
+
58
+ if !prioritize {
59
+ break ;
60
+ }
51
61
}
52
62
}
53
- Err ( error) => log:: error!( "Invalid glob pattern: {}" , error) ,
63
+
64
+ if prioritize {
65
+ return Ok ( Some ( Prioritize :: Label ) ) ;
66
+ }
54
67
}
55
68
}
56
69
}
0 commit comments