@@ -3,36 +3,36 @@ use std::borrow::Cow;
33use anyhow:: bail;
44
55use crate :: {
6+ config:: RenderedLinkConfig ,
67 github:: { Event , IssuesAction , IssuesEvent } ,
78 handlers:: Context ,
89} ;
910
10- pub async fn handle ( ctx : & Context , event : & Event ) -> anyhow:: Result < ( ) > {
11- let e = if let Event :: Issue ( e) = event {
12- e
13- } else {
11+ pub async fn handle (
12+ ctx : & Context ,
13+ event : & Event ,
14+ config : & RenderedLinkConfig ,
15+ ) -> anyhow:: Result < ( ) > {
16+ let Event :: Issue ( e) = event else {
1417 return Ok ( ( ) ) ;
1518 } ;
1619
1720 if !e. issue . is_pr ( ) {
1821 return Ok ( ( ) ) ;
1922 }
2023
21- let repo = e. issue . repository ( ) ;
22- let prefix = match ( & * repo. organization , & * repo. repository ) {
23- ( "rust-lang" , "rfcs" ) => "text/" ,
24- ( "rust-lang" , "blog.rust-lang.org" ) => "posts/" ,
25- _ => return Ok ( ( ) ) ,
26- } ;
27-
28- if let Err ( e) = add_rendered_link ( & ctx, & e, prefix) . await {
24+ if let Err ( e) = add_rendered_link ( & ctx, & e, config) . await {
2925 tracing:: error!( "Error adding rendered link: {:?}" , e) ;
3026 }
3127
3228 Ok ( ( ) )
3329}
3430
35- async fn add_rendered_link ( ctx : & Context , e : & IssuesEvent , prefix : & str ) -> anyhow:: Result < ( ) > {
31+ async fn add_rendered_link (
32+ ctx : & Context ,
33+ e : & IssuesEvent ,
34+ config : & RenderedLinkConfig ,
35+ ) -> anyhow:: Result < ( ) > {
3636 if e. action == IssuesAction :: Opened
3737 || e. action == IssuesAction :: Closed
3838 || e. action == IssuesAction :: Reopened
@@ -42,7 +42,12 @@ async fn add_rendered_link(ctx: &Context, e: &IssuesEvent, prefix: &str) -> anyh
4242
4343 let rendered_link = files
4444 . iter ( )
45- . find ( |f| f. filename . starts_with ( prefix) )
45+ . find ( |f| {
46+ config
47+ . trigger_files
48+ . iter ( )
49+ . any ( |tf| f. filename . starts_with ( tf) )
50+ } )
4651 . map ( |file| {
4752 let head = e. issue . head . as_ref ( ) . unwrap ( ) ;
4853 let base = e. issue . base . as_ref ( ) . unwrap ( ) ;
0 commit comments