Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ impl FileProcessor {
.filter_map(|e| e.ok())
.filter(|e| e.file_type().is_file())
.filter(|e| {
!e.path()
.file_name()
.and_then(|n| n.to_str())
.is_some_and(|s| s.starts_with('.'))
// Skip hidden files, but allow common configuration files
if let Some(filename) = e.path().file_name().and_then(|n| n.to_str()) {
if filename.starts_with('.') {
// Allow common configuration files
filename.ends_with("rc")
|| filename.ends_with("config")
|| matches!(filename, ".gitignore" | ".env" | ".dockerignore")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a CONSTANT so we we can use this collection in both places.

} else {
true
}
} else {
true
}
})
.filter(|e| {
pattern_filter
Expand Down
19 changes: 12 additions & 7 deletions crates/semantic-search-client/src/client/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,18 @@ impl SemanticSearchClient {
{
let path = entry.path();

// Skip hidden files
if path
.file_name()
.and_then(|n| n.to_str())
.is_some_and(|s| s.starts_with('.'))
{
continue;
// Skip hidden files, but allow common configuration files
if let Some(filename) = path.file_name().and_then(|n| n.to_str()) {
if filename.starts_with('.') {
// Allow common configuration files
let is_config_file = filename.ends_with("rc")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constant or utility for this?

|| filename.ends_with("config")
|| matches!(filename, ".gitignore" | ".env" | ".dockerignore");

if !is_config_file {
continue;
}
}
}

// Process the file
Expand Down
19 changes: 12 additions & 7 deletions crates/semantic-search-client/src/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,18 @@ where
{
let path = entry.path();

// Skip hidden files
if path
.file_name()
.and_then(|n| n.to_str())
.is_some_and(|s| s.starts_with('.'))
{
continue;
// Skip hidden files, but allow common configuration files
if let Some(filename) = path.file_name().and_then(|n| n.to_str()) {
if filename.starts_with('.') {
// Allow common configuration files
let is_config_file = filename.ends_with("rc")
|| filename.ends_with("config")
|| matches!(filename, ".gitignore" | ".env" | ".dockerignore");

if !is_config_file {
continue;
}
}
}

file_count += 1;
Expand Down
31 changes: 23 additions & 8 deletions crates/semantic-search-client/src/processing/file_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ pub fn get_file_type(path: &Path) -> FileType {
Some("Dockerfile" | "Makefile" | "LICENSE" | "CHANGELOG" | "README") => FileType::Text,
Some(name) if name.starts_with('.') => match name {
".gitignore" | ".env" | ".dockerignore" => FileType::Text,
_ => FileType::Unknown,
// Treat other dotfiles as text if they appear to be configuration files
name if name.ends_with("rc") || name.ends_with("config") => FileType::Text,
// Default other dotfiles to text for better indexing
_ => FileType::Text,
},
_ => FileType::Unknown,
},
Expand Down Expand Up @@ -205,13 +208,18 @@ pub fn process_directory(
{
let path = entry.path();

// Skip hidden files
if path
.file_name()
.and_then(|n| n.to_str())
.is_some_and(|s| s.starts_with('.'))
{
continue;
// Skip hidden files, but allow common configuration files
if let Some(filename) = path.file_name().and_then(|n| n.to_str()) {
if filename.starts_with('.') {
// Allow common configuration files
let is_config_file = filename.ends_with("rc")
|| filename.ends_with("config")
|| matches!(filename, ".gitignore" | ".env" | ".dockerignore");

if !is_config_file {
continue;
}
}
}

// Process the file
Expand Down Expand Up @@ -256,6 +264,13 @@ mod tests {
("Dockerfile", FileType::Text),
("LICENSE", FileType::Text),
(".gitignore", FileType::Text),
(".bashrc", FileType::Text),
(".vimrc", FileType::Text),
(".raprc", FileType::Text),
(".testrc", FileType::Text),
(".zshconfig", FileType::Text),
(".someconfig", FileType::Text),
(".randomdotfile", FileType::Text),
// Case insensitive
("Main.RS", FileType::Code),
("README.MD", FileType::Markdown),
Expand Down