mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-27 21:51:33 +02:00
Skip search for ignores when not needed (#644)
This commit is contained in:
parent
4c3b9f0960
commit
345eda871b
@ -93,13 +93,17 @@ pub async fn vcs_types(origin: &Path) -> Vec<ProjectType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn ignores(args: &Args, vcs_types: &[ProjectType], origin: &Path) -> Vec<IgnoreFile> {
|
pub async fn ignores(args: &Args, vcs_types: &[ProjectType], origin: &Path) -> Vec<IgnoreFile> {
|
||||||
|
let mut skip_git_global_excludes = false;
|
||||||
|
|
||||||
|
let mut ignores = if args.no_project_ignore {
|
||||||
|
Vec::new()
|
||||||
|
} else {
|
||||||
let (mut ignores, errors) = ignore_files::from_origin(origin).await;
|
let (mut ignores, errors) = ignore_files::from_origin(origin).await;
|
||||||
for err in errors {
|
for err in errors {
|
||||||
warn!("while discovering project-local ignore files: {}", err);
|
warn!("while discovering project-local ignore files: {}", err);
|
||||||
}
|
}
|
||||||
debug!(?ignores, "discovered ignore files from project origin");
|
debug!(?ignores, "discovered ignore files from project origin");
|
||||||
|
|
||||||
let mut skip_git_global_excludes = false;
|
|
||||||
if !vcs_types.is_empty() {
|
if !vcs_types.is_empty() {
|
||||||
ignores = ignores
|
ignores = ignores
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -122,6 +126,12 @@ pub async fn ignores(args: &Args, vcs_types: &[ProjectType], origin: &Path) -> V
|
|||||||
debug!(?ignores, "filtered ignores to only those for project vcs");
|
debug!(?ignores, "filtered ignores to only those for project vcs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ignores
|
||||||
|
};
|
||||||
|
|
||||||
|
let global_ignores = if args.no_global_ignore {
|
||||||
|
Vec::new()
|
||||||
|
} else {
|
||||||
let (mut global_ignores, errors) = ignore_files::from_environment(Some("watchexec")).await;
|
let (mut global_ignores, errors) = ignore_files::from_environment(Some("watchexec")).await;
|
||||||
for err in errors {
|
for err in errors {
|
||||||
warn!("while discovering global ignore files: {}", err);
|
warn!("while discovering global ignore files: {}", err);
|
||||||
@ -148,6 +158,9 @@ pub async fn ignores(args: &Args, vcs_types: &[ProjectType], origin: &Path) -> V
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global_ignores
|
||||||
|
};
|
||||||
|
|
||||||
ignores.extend(global_ignores.into_iter().filter(|ig| match ig.applies_to {
|
ignores.extend(global_ignores.into_iter().filter(|ig| match ig.applies_to {
|
||||||
Some(pt) if pt.is_vcs() => vcs_types.contains(&pt),
|
Some(pt) if pt.is_vcs() => vcs_types.contains(&pt),
|
||||||
_ => true,
|
_ => true,
|
||||||
|
Loading…
Reference in New Issue
Block a user