@@ -39,7 +39,10 @@ pub(super) async fn parse_input(
39
39
// synchronize may be straddling a rebase, which will break diff generation.
40
40
if matches ! (
41
41
event. action,
42
- IssuesAction :: Opened | IssuesAction :: Synchronize | IssuesAction :: ReadyForReview
42
+ IssuesAction :: Opened
43
+ | IssuesAction :: Synchronize
44
+ | IssuesAction :: ReadyForReview
45
+ | IssuesAction :: ConvertedToDraft
43
46
) {
44
47
let mut db = ctx. db . get ( ) . await ;
45
48
let mut state: IssueData < ' _ , AutolabelState > =
@@ -55,7 +58,9 @@ pub(super) async fn parse_input(
55
58
log:: error!( "failed to fetch diff: {:?}" , e) ;
56
59
} )
57
60
. unwrap_or_default ( ) ;
61
+
58
62
let mut autolabels = Vec :: new ( ) ;
63
+ let mut to_remove = Vec :: new ( ) ;
59
64
60
65
' outer: for ( label, cfg) in config. labels . iter ( ) {
61
66
let exclude_patterns: Vec < glob:: Pattern > = cfg
@@ -108,6 +113,14 @@ pub(super) async fn parse_input(
108
113
} ) ;
109
114
state. data . new_pr_labels_applied = true ;
110
115
}
116
+
117
+ // If a PR is converted to draft remove all the "new PR" labels
118
+ if cfg. new_pr && event. action == IssuesAction :: ConvertedToDraft {
119
+ to_remove. push ( Label {
120
+ name : label. to_owned ( ) ,
121
+ } ) ;
122
+ state. data . new_pr_labels_applied = false ;
123
+ }
111
124
} else {
112
125
if cfg. new_issue && event. action == IssuesAction :: Opened {
113
126
autolabels. push ( Label {
@@ -119,10 +132,10 @@ pub(super) async fn parse_input(
119
132
120
133
state. save ( ) . await . map_err ( |e| e. to_string ( ) ) ?;
121
134
122
- if !autolabels. is_empty ( ) {
135
+ if !autolabels. is_empty ( ) || !to_remove . is_empty ( ) {
123
136
return Ok ( Some ( AutolabelInput {
124
137
add : autolabels,
125
- remove : vec ! [ ] ,
138
+ remove : to_remove ,
126
139
} ) ) ;
127
140
}
128
141
}
0 commit comments