fix gitignore performance issues
This commit is contained in:
1 parent
31e21aaa79
commit
34c8ad8849
2 files changed
+11
-10
No files matched your search
@@ -23,4 +23,4 @@ serde_json = "1.0.91"
|
|||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
execute = "0.2.11"
|
execute = "0.2.11"
|
||||||
once_cell = "1.17.0"
|
once_cell = "1.17.0"
|
||||||
gitignore = "1.0.7"
|
ignore = "0.4.19"
|
||||||
@@ -166,7 +166,7 @@ pub fn init<Ctx: HotReloadingContext + Send + 'static>(cfg: Config<Ctx>) {
|
|||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
// try to find the gitingore file
|
// try to find the gitingore file
|
||||||
let gitignore_file_path = crate_dir.join(".gitignore");
|
let gitignore_file_path = crate_dir.join(".gitignore");
|
||||||
let gitignore_file = gitignore::File::new(&gitignore_file_path.as_path());
|
let (gitignore, _) = ignore::gitignore::Gitignore::new(gitignore_file_path);
|
||||||
|
|
||||||
let mut last_update_time = chrono::Local::now().timestamp();
|
let mut last_update_time = chrono::Local::now().timestamp();
|
||||||
|
|
||||||
@@ -220,15 +220,16 @@ pub fn init<Ctx: HotReloadingContext + Send + 'static>(cfg: Config<Ctx>) {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(|path| {
|
.filter(|path| {
|
||||||
// skip non rust files
|
// skip non rust files
|
||||||
matches!(path.extension().and_then(|p| p.to_str()), Some("rs" | "toml" | "css" | "html" | "js")) &&
|
matches!(
|
||||||
|
path.extension().and_then(|p| p.to_str()),
|
||||||
|
Some("rs" | "toml" | "css" | "html" | "js")
|
||||||
|
)&&
|
||||||
// skip excluded paths
|
// skip excluded paths
|
||||||
!excluded_paths.iter().any(|p| path.starts_with(p)) && match &gitignore_file{
|
!excluded_paths.iter().any(|p| path.starts_with(p)) &&
|
||||||
Ok(file) => match file.is_excluded(path){
|
// respect .gitignore
|
||||||
Ok(excluded) => !excluded,
|
!gitignore
|
||||||
Err(_) => true,
|
.matched_path_or_any_parents(path, false)
|
||||||
},
|
.is_ignore()
|
||||||
Err(_) => true,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user