1- use anyhow:: Result ;
21use chrono:: { Duration , NaiveDateTime } ;
2+ use color_eyre:: {
3+ eyre:: { Result , WrapErr } ,
4+ Section , SectionExt ,
5+ } ;
36use itertools:: Itertools ;
47use reqwest:: header:: { AUTHORIZATION , USER_AGENT } ;
58use serde:: de:: { DeserializeOwned , Deserializer } ;
@@ -124,6 +127,7 @@ impl Generator {
124127 . labels ( & [ "T-libs-api" , "stable-nominated" ] )
125128 . labels ( & [ "T-libs" , "beta-nominated" ] )
126129 . labels ( & [ "T-libs-api" , "beta-nominated" ] )
130+ . exclude_labels ( & [ "beta-accepted" ] )
127131 . state ( State :: Any )
128132 . repo ( "rust-lang/rust" )
129133 . repo ( "rust-lang/rfcs" )
@@ -410,6 +414,7 @@ impl Sort {
410414struct GithubQuery {
411415 name : & ' static str ,
412416 labels : Vec < & ' static [ & ' static str ] > ,
417+ excluded_labels : Vec < & ' static [ & ' static str ] > ,
413418 repos : Vec < & ' static str > ,
414419 sort : Option < Sort > ,
415420 count : Option < usize > ,
@@ -446,6 +451,7 @@ impl GithubQuery {
446451 Self {
447452 name,
448453 labels : vec ! [ ] ,
454+ excluded_labels : vec ! [ ] ,
449455 repos : vec ! [ ] ,
450456 sort : None ,
451457 count : None ,
@@ -458,6 +464,11 @@ impl GithubQuery {
458464 self
459465 }
460466
467+ fn exclude_labels ( & mut self , labels : & ' static [ & ' static str ] ) -> & mut Self {
468+ self . excluded_labels . push ( labels) ;
469+ self
470+ }
471+
461472 fn repo ( & mut self , repo : & ' static str ) -> & mut Self {
462473 self . repos . push ( repo) ;
463474 self
@@ -497,6 +508,15 @@ impl GithubQuery {
497508
498509 let issues = github_api ( & endpoint) ?;
499510 let issues = generator. dedup ( issues) ;
511+
512+ let issues = issues. filter ( |issue| {
513+ !self . excluded_labels . iter ( ) . any ( |labels| {
514+ labels
515+ . iter ( )
516+ . all ( |& label| issue. labels . iter ( ) . any ( |x| x == label) )
517+ } )
518+ } ) ;
519+
500520 let issues: Vec < _ > = if let Some ( count) = self . count {
501521 issues. take ( count) . collect ( )
502522 } else {
@@ -585,7 +605,10 @@ fn github_api<T: DeserializeOwned>(endpoint: &str) -> Result<T> {
585605 client = client. header ( AUTHORIZATION , format ! ( "token {}" , token) ) ;
586606 }
587607 let response = client. send ( ) ?;
588- Ok ( response. json ( ) ?)
608+ let response = response. text ( ) ?;
609+ Ok ( serde_json:: from_str ( & response)
610+ . wrap_err ( "response body cannot be deserialized" )
611+ . with_section ( || response. header ( "Response:" ) ) ?)
589612}
590613
591614fn deserialize_labels < ' de , D : Deserializer < ' de > > ( d : D ) -> Result < Vec < String > , D :: Error > {
0 commit comments