Skip to content

Commit 6f20335

Browse files
committed
[lib] Fixed bug where file extension based pruning was breaking search b/c of
how any works Also added some logging to lib
1 parent 96582fd commit 6f20335

File tree

1 file changed

+18
-4
lines changed
  • git-function-history-lib/src

1 file changed

+18
-4
lines changed

git-function-history-lib/src/lib.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use function_grep::{
4343
};
4444
use git_function_history_proc_macro::enumstuff;
4545

46+
use log::{info, warn};
4647
#[cfg(feature = "parallel")]
4748
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
4849

@@ -337,7 +338,7 @@ fn traverse_tree(
337338
langs: &[&InstatiatedLanguage<'_>],
338339
filetype: &FileFilterType,
339340
) -> Result<Vec<ParsedFile>, String> {
340-
let mut files_exts = file_exts.iter();
341+
let mut files_exts_iter = file_exts.iter();
341342
let treee_iter = tree.iter();
342343
let mut files: Vec<_> = Vec::new();
343344
let mut ret = Vec::new();
@@ -364,32 +365,45 @@ fn traverse_tree(
364365
match &filetype {
365366
FileFilterType::Relative(ref path) => {
366367
if !file.ends_with(path) {
368+
info!("{file} was skipped because it was not in path {path}");
367369
continue;
368370
}
369371
}
370372
FileFilterType::Absolute(ref path) => {
371373
if &file != path {
374+
info!("{file} was skipped because it was not the same as path {path}");
372375
continue;
373376
}
374377
}
375378
FileFilterType::Directory(ref path) => {
376379
if !file.contains(path) {
380+
info!("{file} was skipped because it was not in dir {path}");
377381
continue;
378382
}
379383
}
380384
FileFilterType::None => {}
381385
}
382386

383-
if !files_exts.any(|ext| ends_with_cmp_no_case(&file, ext)) {
387+
// we have to clone because any abosrbs elements
388+
// TODO: better solution then clone each time
389+
if !files_exts_iter
390+
.clone()
391+
.any(|ext| ends_with_cmp_no_case(&file, ext))
392+
{
393+
info!(
394+
"{file} was skipped because it was not supported supported {file_exts:?}"
395+
);
384396
continue;
385397
}
386398

387399
let obh = repo
388400
.find_object(i.oid())
389-
.map_err(|_| "failed to find object")?;
401+
.map_err(|e| format!("failed to find object for file {file}: {e}"))
402+
.inspect_err(|e| warn!("{e}"))?;
390403
let blob = obh
391404
.try_into_blob()
392-
.map_err(|e| format!("could not obtain file contents of {file}: {e}"))?;
405+
.map_err(|e| format!("could not obtain file contents of {file}: {e}"))
406+
.inspect_err(|e| warn!("{e}"))?;
393407
files.push((file, String::from_utf8_lossy(&blob.data).to_string()));
394408
}
395409
_ => {}

0 commit comments

Comments
 (0)