@@ -27,43 +27,45 @@ pub(super) async fn parse_input(
27
27
// remove. Not much can be done about that currently; the before/after on
28
28
// synchronize may be straddling a rebase, which will break diff generation.
29
29
if event. action == IssuesAction :: Opened || event. action == IssuesAction :: Synchronize {
30
- if let Some ( diff) = event
30
+ let diff = event
31
31
. issue
32
32
. diff ( & ctx. github )
33
33
. await
34
34
. map_err ( |e| {
35
35
log:: error!( "failed to fetch diff: {:?}" , e) ;
36
36
} )
37
- . unwrap_or_default ( )
38
- {
39
- let files = files_changed ( & diff) ;
40
- let mut autolabels = Vec :: new ( ) ;
41
- ' outer: for ( label, cfg) in config. labels . iter ( ) {
37
+ . unwrap_or_default ( ) ;
38
+ let files = diff. as_deref ( ) . map ( files_changed) ;
39
+ let mut autolabels = Vec :: new ( ) ;
40
+
41
+ ' outer: for ( label, cfg) in config. labels . iter ( ) {
42
+ let exclude_patterns: Vec < glob:: Pattern > = cfg
43
+ . exclude_labels
44
+ . iter ( )
45
+ . filter_map ( |label| match glob:: Pattern :: new ( label) {
46
+ Ok ( exclude_glob) => Some ( exclude_glob) ,
47
+ Err ( error) => {
48
+ log:: error!( "Invalid glob pattern: {}" , error) ;
49
+ None
50
+ }
51
+ } )
52
+ . collect ( ) ;
53
+
54
+ for label in event. issue . labels ( ) {
55
+ for pat in & exclude_patterns {
56
+ if pat. matches ( & label. name ) {
57
+ // If we hit an excluded label, ignore this autolabel and check the next
58
+ continue ' outer;
59
+ }
60
+ }
61
+ }
62
+
63
+ if let Some ( files) = & files {
42
64
if cfg
43
65
. trigger_files
44
66
. iter ( )
45
67
. any ( |f| files. iter ( ) . any ( |diff_file| diff_file. starts_with ( f) ) )
46
68
{
47
- let exclude_patterns: Vec < glob:: Pattern > = cfg
48
- . exclude_labels
49
- . iter ( )
50
- . filter_map ( |label| match glob:: Pattern :: new ( label) {
51
- Ok ( exclude_glob) => Some ( exclude_glob) ,
52
- Err ( error) => {
53
- log:: error!( "Invalid glob pattern: {}" , error) ;
54
- None
55
- }
56
- } )
57
- . collect ( ) ;
58
- for label in event. issue . labels ( ) {
59
- for pat in & exclude_patterns {
60
- if pat. matches ( & label. name ) {
61
- // If we hit an excluded label, ignore this autolabel and check the next
62
- continue ' outer;
63
- }
64
- }
65
- }
66
-
67
69
autolabels. push ( Label {
68
70
name : label. to_owned ( ) ,
69
71
} ) ;
@@ -74,13 +76,23 @@ pub(super) async fn parse_input(
74
76
} ) ;
75
77
}
76
78
}
77
- if !autolabels. is_empty ( ) {
78
- return Ok ( Some ( AutolabelInput {
79
- add : autolabels,
80
- remove : vec ! [ ] ,
81
- } ) ) ;
79
+
80
+ if event. issue . pull_request . is_none ( )
81
+ && cfg. new_issue
82
+ && event. action == IssuesAction :: Opened
83
+ {
84
+ autolabels. push ( Label {
85
+ name : label. to_owned ( ) ,
86
+ } ) ;
82
87
}
83
88
}
89
+
90
+ if !autolabels. is_empty ( ) {
91
+ return Ok ( Some ( AutolabelInput {
92
+ add : autolabels,
93
+ remove : vec ! [ ] ,
94
+ } ) ) ;
95
+ }
84
96
}
85
97
86
98
if event. action == IssuesAction :: Labeled {
0 commit comments