@@ -87,11 +87,18 @@ impl App {
8787
8888 fn run_check ( & self , paths : Vec < PathBuf > ) -> Result < ExitCode > {
8989 let start = std:: time:: Instant :: now ( ) ;
90- let git_range = self . active_git_range ( ) ;
9190 let check_root = self . check_root ( & paths) ?;
9291
92+ let git_range = match self . active_git_range ( ) {
93+ Some ( raw) => match GitRepo :: discover ( & check_root) {
94+ Ok ( repo) => Some ( repo. expand_git_range ( & raw ) ?) ,
95+ Err ( _) => Some ( raw) ,
96+ } ,
97+ None => None ,
98+ } ;
99+
93100 let files = if paths. is_empty ( ) {
94- self . discover_files_at ( & check_root) ?
101+ self . discover_files_at ( & check_root, git_range . as_deref ( ) ) ?
95102 } else {
96103 // Explicit files pass through; directories use the same
97104 // git-aware discovery as the no-paths case.
@@ -105,7 +112,7 @@ impl App {
105112 }
106113 }
107114 for dir in & dirs {
108- files. extend ( self . discover_files_at ( dir) ?) ;
115+ files. extend ( self . discover_files_at ( dir, git_range . as_deref ( ) ) ?) ;
109116 }
110117 files
111118 } ;
@@ -232,7 +239,11 @@ impl App {
232239 self . cli . get_git ( ) . or ( self . config . sizelint . git . clone ( ) )
233240 }
234241
235- fn discover_files_at ( & self , root : & std:: path:: Path ) -> Result < Vec < PathBuf > > {
242+ fn discover_files_at (
243+ & self ,
244+ root : & std:: path:: Path ,
245+ git_range : Option < & str > ,
246+ ) -> Result < Vec < PathBuf > > {
236247 let discovery = FileDiscovery :: new ( root, & self . config . sizelint . excludes ) ?;
237248
238249 debug ! ( "Discovering files..." ) ;
@@ -247,16 +258,16 @@ impl App {
247258 {
248259 print_progress ( "Checking working tree files (git diff)" ) ;
249260 discovery. discover_working_tree_files ( )
250- } else if let Some ( range) = self . cli . get_git ( ) . or ( self . config . sizelint . git . clone ( ) ) {
261+ } else if let Some ( range) = git_range {
251262 let commit_count = discovery
252263 . git_repo ( )
253- . map ( |r| r. count_commits_in_range ( & range) . unwrap_or ( 0 ) )
264+ . map ( |r| r. count_commits_in_range ( range) . unwrap_or ( 0 ) )
254265 . unwrap_or ( 0 ) ;
255266 print_progress ( & format ! (
256267 "Checking git range: {range} ({commit_count} commit{})" ,
257268 if commit_count == 1 { "" } else { "s" }
258269 ) ) ;
259- discovery. discover_git_diff_files ( & range)
270+ discovery. discover_git_diff_files ( range)
260271 } else {
261272 print_progress ( "Checking all files (directory walk)" ) ;
262273 discovery. discover_files ( self . config . sizelint . respect_gitignore )
0 commit comments