Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
seren5240 committed Mar 13, 2024
1 parent 3df3699 commit 5cbd2e9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/language/src/target_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ fn find_ignore_files(start_path: &Path, name: &str) -> Result<Vec<PathBuf>> {
let mut current_path = start_path.absolutize()?.canonicalize()?;
while let Some(parent) = current_path.parent() {
let gitignore_path = parent.join(name);
println!("Checking gitignore path {}, next parent is {:?}", gitignore_path.display(), parent.parent().map(|p| p.display()));
if gitignore_path.exists() && gitignore_path.is_file() {
gitignore_files.push(gitignore_path);
}
Expand All @@ -402,6 +401,7 @@ fn find_ignore_files(start_path: &Path, name: &str) -> Result<Vec<PathBuf>> {
#[cfg(feature = "finder")]
fn is_file_ignored(path: &Path) -> Result<bool> {
use ignore::{gitignore::GitignoreBuilder, Match};
use path_absolutize::Absolutize;

let git_ignores = find_ignore_files(path, ".gitignore")?;
let grit_ignores = find_ignore_files(path, ".gritignore")?;
Expand All @@ -413,7 +413,9 @@ fn is_file_ignored(path: &Path) -> Result<bool> {
let mut ignore_builder = GitignoreBuilder::new(ignore_dir);
ignore_builder.add(ignore_file);
let ignorer = ignore_builder.build()?;
if let Match::Ignore(_) = ignorer.matched(path, false) {
let relativized_path = path.absolutize()?.canonicalize()?;
relativized_path.strip_prefix(ignore_dir)?;
if let Match::Ignore(_) = ignorer.matched(relativized_path, false) {
return Ok(true);
}
}
Expand Down

0 comments on commit 5cbd2e9

Please sign in to comment.