File tree Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -1219,7 +1219,7 @@ pub struct CommitBase {
1219
1219
pub sha : String ,
1220
1220
#[ serde( rename = "ref" ) ]
1221
1221
pub git_ref : String ,
1222
- pub repo : Repository ,
1222
+ pub repo : Option < Repository > ,
1223
1223
}
1224
1224
1225
1225
pub fn parse_diff ( diff : & str ) -> Vec < FileDiff > {
Original file line number Diff line number Diff line change @@ -48,9 +48,9 @@ async fn add_rendered_link(
48
48
. iter ( )
49
49
. any ( |tf| f. filename . starts_with ( tf) )
50
50
} )
51
- . map ( |file| {
52
- let head = e. issue . head . as_ref ( ) . unwrap ( ) ;
53
- let base = e. issue . base . as_ref ( ) . unwrap ( ) ;
51
+ . and_then ( |file| {
52
+ let head = e. issue . head . as_ref ( ) ? ;
53
+ let base = e. issue . base . as_ref ( ) ? ;
54
54
55
55
// This URL should be stable while the PR is open, even if the
56
56
// user pushes new commits.
@@ -68,12 +68,12 @@ async fn add_rendered_link(
68
68
// - if merged: `https://github.com/octocat/REPO/blob/master/FILEPATH`
69
69
// - if open: `https://github.com/Bob/REPO/blob/patch-1/FILEPATH`
70
70
// - if closed: `https://github.com/octocat/REPO/blob/SHA/FILEPATH`
71
- format ! (
71
+ Some ( format ! (
72
72
"[Rendered](https://github.com/{}/blob/{}/{})" ,
73
73
if e. issue. merged || e. action == IssuesAction :: Closed {
74
74
& e. repository. full_name
75
75
} else {
76
- & head. repo. full_name
76
+ & head. repo. as_ref ( ) ? . full_name
77
77
} ,
78
78
if e. issue. merged {
79
79
& base. git_ref
@@ -83,7 +83,7 @@ async fn add_rendered_link(
83
83
& head. git_ref
84
84
} ,
85
85
file. filename
86
- )
86
+ ) )
87
87
} ) ;
88
88
89
89
let new_body: Cow < ' _ , str > = if !e. issue . body . contains ( "[Rendered]" ) {
Original file line number Diff line number Diff line change @@ -42,9 +42,13 @@ pub(super) async fn parse_input(
42
42
log:: error!( "expected head commit in {event:?}" ) ;
43
43
return Ok ( None ) ;
44
44
} ;
45
+ let Some ( repo) = & pr_source. repo else {
46
+ log:: warn!( "repo is not available in {event:?}" ) ;
47
+ return Ok ( None ) ;
48
+ } ;
45
49
let triagebot_content = match ctx
46
50
. github
47
- . raw_file ( & pr_source . repo . full_name , & pr_source. sha , CONFIG_FILE_NAME )
51
+ . raw_file ( & repo. full_name , & pr_source. sha , CONFIG_FILE_NAME )
48
52
. await
49
53
{
50
54
Ok ( Some ( c) ) => c,
@@ -66,7 +70,7 @@ pub(super) async fn parse_input(
66
70
let ( line, col) = translate_position ( & triagebot_content, span. start ) ;
67
71
let url = format ! (
68
72
"https://github.com/{}/blob/{}/{CONFIG_FILE_NAME}#L{line}" ,
69
- pr_source . repo. full_name, pr_source. sha
73
+ repo. full_name, pr_source. sha
70
74
) ;
71
75
format ! ( " at position [{line}:{col}]({url})" , )
72
76
}
You can’t perform that action at this time.
0 commit comments