@@ -15,13 +15,6 @@ static CLOSES_ISSUE_REGEXP: LazyLock<Regex> = LazyLock::new(|| {
1515 Regex :: new ( "(?i)(?P<action>close[sd]*|fix([e]*[sd]*)?|resolve[sd]*)(?P<spaces>:? +)(?P<org_repo>[a-zA-Z0-9_-]*/[a-zA-Z0-9_-]*)?#(?P<issue_num>[0-9]+)" ) . unwrap ( )
1616} ) ;
1717
18- const BACKPORT_LABELS : [ & str ; 4 ] = [
19- "beta-nominated" ,
20- "beta-accepted" ,
21- "stable-nominated" ,
22- "stable-accepted" ,
23- ] ;
24-
2518const REGRESSION_LABELS : [ & str ; 3 ] = [
2619 "regression-from-stable-to-nightly" ,
2720 "regression-from-stable-to-beta" ,
@@ -41,7 +34,7 @@ pub(crate) struct BackportInput {
4134}
4235
4336pub ( super ) async fn parse_input (
44- _ctx : & Context ,
37+ ctx : & Context ,
4538 event : & IssuesEvent ,
4639 config : Option < & BackportConfig > ,
4740) -> Result < Option < BackportInput > , String > {
@@ -69,9 +62,26 @@ pub(super) async fn parse_input(
6962 let pr = & event. issue ;
7063
7164 let pr_labels: Vec < & str > = pr. labels . iter ( ) . map ( |l| l. name . as_str ( ) ) . collect ( ) ;
72- if contains_any ( & pr_labels, & BACKPORT_LABELS ) {
73- log:: debug!( "PR #{} already has a backport label" , pr. number) ;
74- return Ok ( None ) ;
65+
66+ if let IssuesAction :: Labeled { label } = & event. action {
67+ if ( label. name == "beta-nominated" && contains_any ( & pr_labels, & [ "beta-accepted" ] ) )
68+ || ( label. name == "stable-nominated" && contains_any ( & pr_labels, & [ "stable-accepted" ] ) )
69+ {
70+ log:: debug!(
71+ "Will not nominate for backport, PR #{} is already backport accepted (found labels: {:?})" ,
72+ pr. number,
73+ pr_labels
74+ ) ;
75+ let label_to_remove = vec ! [ Label {
76+ name: label. name. clone( ) ,
77+ } ] ;
78+ let _ = event
79+ . issue
80+ . remove_labels ( & ctx. github , label_to_remove)
81+ . await
82+ . context ( "failed to remove labels from the issue" ) ;
83+ return Ok ( None ) ;
84+ }
7585 }
7686
7787 // Retrieve backport config for this PR, based on its team label(s)
@@ -86,7 +96,7 @@ pub(super) async fn parse_input(
8696 cfg. required_pr_labels . iter ( ) . map ( String :: as_str) . collect ( ) ;
8797 if !contains_any ( & pr_labels, & required_pr_labels) {
8898 log:: warn!(
89- "Skipping backport nomination: PR is missing one required label : {:?}" ,
99+ "Skipping backport nomination: PR is missing the required labels. Labels found : {:?}" ,
90100 pr_labels
91101 ) ;
92102 return false ;
0 commit comments