File tree 2 files changed +13
-6
lines changed
bootstrap/src/core/build_steps
2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ fn update_rustfmt_version(build: &Builder<'_>) {
81
81
}
82
82
83
83
/// Returns the Rust files modified between the `merge-base` of HEAD and
84
- /// rust-lang/master and what is now on the disk.
84
+ /// rust-lang/master and what is now on the disk. Does not include removed files.
85
85
///
86
86
/// Returns `None` if all files should be formatted.
87
87
fn get_modified_rs_files ( build : & Builder < ' _ > ) -> Result < Option < Vec < String > > , String > {
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ pub fn get_git_merge_base(
113
113
114
114
/// Returns the files that have been modified in the current branch compared to the master branch.
115
115
/// The `extensions` parameter can be used to filter the files by their extension.
116
+ /// Does not include removed files.
116
117
/// If `extensions` is empty, all files will be returned.
117
118
pub fn get_git_modified_files (
118
119
config : & GitConfig < ' _ > ,
@@ -125,13 +126,19 @@ pub fn get_git_modified_files(
125
126
if let Some ( git_dir) = git_dir {
126
127
git. current_dir ( git_dir) ;
127
128
}
128
- let files = output_result ( git. args ( [ "diff-index" , "--name-only " , merge_base. trim ( ) ] ) ) ?
129
+ let files = output_result ( git. args ( [ "diff-index" , "--name-status " , merge_base. trim ( ) ] ) ) ?
129
130
. lines ( )
130
- . map ( |s| s. trim ( ) . to_owned ( ) )
131
- . filter ( |f| {
132
- Path :: new ( f) . extension ( ) . map_or ( false , |ext| {
131
+ . filter_map ( |f| {
132
+ let ( status, name) = f. trim ( ) . split_once ( char:: is_whitespace) . unwrap ( ) ;
133
+ if status == "D" {
134
+ None
135
+ } else if Path :: new ( name) . extension ( ) . map_or ( false , |ext| {
133
136
extensions. is_empty ( ) || extensions. contains ( & ext. to_str ( ) . unwrap ( ) )
134
- } )
137
+ } ) {
138
+ Some ( name. to_owned ( ) )
139
+ } else {
140
+ None
141
+ }
135
142
} )
136
143
. collect ( ) ;
137
144
Ok ( Some ( files) )
You can’t perform that action at this time.
0 commit comments