Skip to content

Commit f17ccbb

Browse files
committed
fix(oxlint,oxfmt): Skip traversing .git directories
fixes #13315 `.git` is not a special case for `.hidden(false)`. See BurntSushi/ripgrep#3099 (comment) Only tested this manually, can't really create a reproduction ...
1 parent c4e12df commit f17ccbb

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

apps/oxfmt/src/walk.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@ impl ignore::ParallelVisitor for WalkVisitor {
3232
fn visit(&mut self, entry: Result<ignore::DirEntry, ignore::Error>) -> ignore::WalkState {
3333
match entry {
3434
Ok(entry) => {
35-
// Skip if we can't get file type or if it's a directory
36-
if let Some(file_type) = entry.file_type()
37-
&& !file_type.is_dir()
38-
&& let Some(source_type) = get_supported_source_type(entry.path())
39-
{
35+
let Some(file_type) = entry.file_type() else {
36+
return ignore::WalkState::Continue;
37+
};
38+
if file_type.is_dir() {
39+
// Skip traversing `.git` directories because `.git` is not a special case for `.hidden(false)`.
40+
// <https://github.com/BurntSushi/ripgrep/issues/3099#issuecomment-3052460027>
41+
if entry.file_name() == ".git" {
42+
return ignore::WalkState::Skip;
43+
}
44+
} else if let Some(source_type) = get_supported_source_type(entry.path()) {
4045
let walk_entry =
4146
WalkEntry { path: entry.path().as_os_str().into(), source_type };
4247
// Send each entry immediately through the channel

apps/oxlint/src/walk.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ impl ignore::ParallelVisitor for WalkCollector {
5252
fn visit(&mut self, entry: Result<ignore::DirEntry, ignore::Error>) -> ignore::WalkState {
5353
match entry {
5454
Ok(entry) => {
55+
// Skip traversing `.git` directories because `.git` is not a special case for `.hidden(false)`.
56+
// <https://github.com/BurntSushi/ripgrep/issues/3099#issuecomment-3052460027>
57+
if entry.file_type().is_some_and(|ty| ty.is_dir()) && entry.file_name() == ".git" {
58+
return ignore::WalkState::Skip;
59+
}
5560
if Walk::is_wanted_entry(&entry, &self.extensions) {
5661
self.paths.push(entry.path().as_os_str().into());
5762
}

0 commit comments

Comments
 (0)