Skip to content

Commit

Permalink
fix: handle Windows paths correctly in gitignore matching
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen1 committed Jan 19, 2025
1 parent c05f6e7 commit b21d45a
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions src/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,45 +248,35 @@ fn collect_files(
let gitignore_path = rel_path
.to_str()
.map(|s| s.replace('\\', "/"))
.map(PathBuf::from)
.unwrap_or(rel_path.to_path_buf());
.unwrap_or_else(|| rel_str.to_string());

#[cfg(not(windows))]
let gitignore_path = rel_path.to_path_buf();
let gitignore_path = rel_str.to_string();

if gitignore.matched(&gitignore_path, false).is_ignore() {
debug!("Skipping {} - matched by gitignore", rel_str);
if gitignore.matched(&path, path.is_dir()).is_ignore() {
continue;
}

// Skip if matched by our ignore patterns
let mut skip = false;
for pat in ignore_patterns {
if pat.is_match(&rel_str) {
debug!("Skipping {} - matched ignore pattern", rel_str);
skip = true;
break;
}
}
if skip {
// Skip if matched by custom ignore patterns
if ignore_patterns.iter().any(|p| p.is_match(&rel_str)) {
continue;
}

// Skip binary files - do this check early to avoid double reads later
let binary_extensions = config
.map(|c| c.binary_extensions.as_slice())
.unwrap_or(&[]);
if !is_text_file(&path, binary_extensions) {
debug!("Skipping binary file: {}", rel_str);
// Skip binary files
if !is_text_file(
&path,
config.map(|c| &c.binary_extensions[..]).unwrap_or(&[]),
) {
continue;
}

// Calculate priority score
// Calculate priority
let mut priority = get_file_priority(&rel_str, ignore_patterns, priority_list);

// Apply git recentness boost
// Apply recentness boost if available
if let Some(boost_map) = recentness_boost {
if let Some(boost) = boost_map.get(&rel_str.to_string()) {
priority += *boost;
if let Some(boost) = boost_map.get(&gitignore_path) {
priority += boost;
}
}

Expand Down

0 comments on commit b21d45a

Please sign in to comment.