File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -1100,6 +1100,9 @@ pub struct PullRequestFile {
1100
1100
pub sha : String ,
1101
1101
pub filename : String ,
1102
1102
pub blob_url : String ,
1103
+ pub additions : u64 ,
1104
+ pub deletions : u64 ,
1105
+ pub changes : u64 ,
1103
1106
}
1104
1107
1105
1108
#[ derive( Debug , serde:: Deserialize ) ]
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ async fn add_rendered_link(
42
42
43
43
let rendered_link = files
44
44
. iter ( )
45
- . find ( |f| {
45
+ . filter ( |f| {
46
46
config
47
47
. trigger_files
48
48
. iter ( )
@@ -52,7 +52,10 @@ async fn add_rendered_link(
52
52
. iter ( )
53
53
. any ( |tf| f. filename . starts_with ( tf) )
54
54
} )
55
- . and_then ( |file| {
55
+ // Sort the relavant files by the total number of lines changed, as to
56
+ // improve our guess for the relevant file to show the link to.
57
+ . max_by_key ( |f| f. additions + f. deletions + f. changes )
58
+ . map ( |file| {
56
59
let head = e. issue . head . as_ref ( ) ?;
57
60
let base = e. issue . base . as_ref ( ) ?;
58
61
@@ -88,7 +91,8 @@ async fn add_rendered_link(
88
91
} ,
89
92
file. filename
90
93
) )
91
- } ) ;
94
+ } )
95
+ . flatten ( ) ;
92
96
93
97
let new_body: Cow < ' _ , str > = if !e. issue . body . contains ( "[Rendered]" ) {
94
98
if let Some ( rendered_link) = rendered_link {
You can’t perform that action at this time.
0 commit comments