File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
bootstrap/src/core/build_steps Expand file tree Collapse file tree 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<'_>) {
8181}
8282
8383/// 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.
8585///
8686/// Returns `None` if all files should be formatted.
8787fn 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(
113113
114114/// Returns the files that have been modified in the current branch compared to the master branch.
115115/// The `extensions` parameter can be used to filter the files by their extension.
116+ /// Does not include removed files.
116117/// If `extensions` is empty, all files will be returned.
117118pub fn get_git_modified_files (
118119 config : & GitConfig < ' _ > ,
@@ -125,13 +126,19 @@ pub fn get_git_modified_files(
125126 if let Some ( git_dir) = git_dir {
126127 git. current_dir ( git_dir) ;
127128 }
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 ( ) ] ) ) ?
129130 . 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| {
133136 extensions. is_empty ( ) || extensions. contains ( & ext. to_str ( ) . unwrap ( ) )
134- } )
137+ } ) {
138+ Some ( name. to_owned ( ) )
139+ } else {
140+ None
141+ }
135142 } )
136143 . collect ( ) ;
137144 Ok ( Some ( files) )
You can’t perform that action at this time.
0 commit comments