@@ -96,20 +96,33 @@ pub(super) async fn parse_input(
96
96
}
97
97
}
98
98
99
+ let is_opened =
100
+ matches ! ( event. action, IssuesAction :: Opened | IssuesAction :: Reopened ) ;
101
+
99
102
// Treat the following situations as a "new PR":
100
103
// 1) PRs that were (re)opened and are not draft
101
104
// 2) PRs that have been converted from a draft to being "ready for review"
102
- let is_opened_non_draft =
103
- matches ! ( event. action, IssuesAction :: Opened | IssuesAction :: Reopened )
104
- && !event. issue . draft ;
105
+ let is_opened_non_draft = is_opened && !event. issue . draft ;
105
106
let is_ready_for_review = event. action == IssuesAction :: ReadyForReview ;
107
+
108
+ // Treat the following situations as a "new draft":
109
+ // 1) PRs that were (re)opened and are draft
110
+ // 2) PRs that have been converted to a draft
111
+ let is_opened_as_draft = is_opened && event. issue . draft ;
112
+ let is_converted_to_draft = event. action == IssuesAction :: ConvertedToDraft ;
113
+
106
114
if cfg. new_pr && ( is_opened_non_draft || is_ready_for_review) {
107
115
autolabels. push ( Label {
108
116
name : label. to_owned ( ) ,
109
117
} ) ;
118
+ } else if cfg. new_draft && ( is_opened_as_draft || is_converted_to_draft) {
119
+ autolabels. push ( Label {
120
+ name : label. to_owned ( ) ,
121
+ } ) ;
110
122
}
111
123
112
- // If a PR is converted to draft or closed, remove all the "new PR" labels
124
+ // If a PR is converted to draft or closed, remove all the "new PR" labels.
125
+ // Same for "new draft" labels when the PR is ready for review or closed.
113
126
if cfg. new_pr
114
127
&& matches ! (
115
128
event. action,
@@ -119,6 +132,15 @@ pub(super) async fn parse_input(
119
132
to_remove. push ( Label {
120
133
name : label. to_owned ( ) ,
121
134
} ) ;
135
+ } else if cfg. new_draft
136
+ && matches ! (
137
+ event. action,
138
+ IssuesAction :: ReadyForReview | IssuesAction :: Closed
139
+ )
140
+ {
141
+ to_remove. push ( Label {
142
+ name : label. to_owned ( ) ,
143
+ } ) ;
122
144
}
123
145
} else {
124
146
if cfg. new_issue && event. action == IssuesAction :: Opened {
0 commit comments