Handle errors from ignore file discovery
This commit is contained in:
parent
3d32f2d24b
commit
2682dde41d
|
@ -34,16 +34,25 @@ pub async fn dirs(args: &ArgMatches<'static>) -> Result<(PathBuf, PathBuf)> {
|
||||||
Ok((project_origin, workdir))
|
Ok((project_origin, workdir))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn ignores(args: &ArgMatches<'static>, origin: &Path) -> Result<Vec<IgnoreFile>> {
|
pub async fn vcs_types(origin: &Path) -> Vec<ProjectType> {
|
||||||
let vcs_types = project::types(origin)
|
let vcs_types = project::types(origin)
|
||||||
.await
|
.await
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|pt| pt.is_vcs())
|
.filter(|pt| pt.is_vcs())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
debug!(?vcs_types, "resolved vcs types");
|
debug!(?vcs_types, "resolved vcs types");
|
||||||
|
vcs_types
|
||||||
|
}
|
||||||
|
|
||||||
let (mut ignores, _errors) = ignore::from_origin(origin).await;
|
pub async fn ignores(
|
||||||
// TODO: handle errors
|
args: &ArgMatches<'static>,
|
||||||
|
vcs_types: &[ProjectType],
|
||||||
|
origin: &Path,
|
||||||
|
) -> Result<Vec<IgnoreFile>> {
|
||||||
|
let (mut ignores, errors) = ignore::from_origin(origin).await;
|
||||||
|
for err in errors {
|
||||||
|
warn!("while discovering project-local ignore files: {}", err);
|
||||||
|
}
|
||||||
debug!(?ignores, "discovered ignore files from project origin");
|
debug!(?ignores, "discovered ignore files from project origin");
|
||||||
|
|
||||||
// TODO: use drain_ignore instead for x = x.filter()... when that stabilises
|
// TODO: use drain_ignore instead for x = x.filter()... when that stabilises
|
||||||
|
@ -71,8 +80,10 @@ pub async fn ignores(args: &ArgMatches<'static>, origin: &Path) -> Result<Vec<Ig
|
||||||
debug!(?ignores, "filtered ignores to only those for project vcs");
|
debug!(?ignores, "filtered ignores to only those for project vcs");
|
||||||
}
|
}
|
||||||
|
|
||||||
let (mut global_ignores, _errors) = ignore::from_environment().await;
|
let (mut global_ignores, errors) = ignore::from_environment().await;
|
||||||
// TODO: handle errors
|
for err in errors {
|
||||||
|
warn!("while discovering global ignore files: {}", err);
|
||||||
|
}
|
||||||
debug!(?global_ignores, "discovered ignore files from environment");
|
debug!(?global_ignores, "discovered ignore files from environment");
|
||||||
|
|
||||||
if skip_git_global_excludes {
|
if skip_git_global_excludes {
|
||||||
|
@ -134,7 +145,5 @@ pub async fn ignores(args: &ArgMatches<'static>, origin: &Path) -> Result<Vec<Ig
|
||||||
debug!(?ignores, "filtered ignores to exclude VCS-specific ignores");
|
debug!(?ignores, "filtered ignores to exclude VCS-specific ignores");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: --no-default-ignore (whatever that was)
|
|
||||||
|
|
||||||
Ok(ignores)
|
Ok(ignores)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,18 +3,20 @@ use std::sync::Arc;
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use futures::future::try_join_all;
|
use futures::future::try_join_all;
|
||||||
use miette::{IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use tracing::{debug, trace};
|
use tracing::{debug, trace, warn};
|
||||||
use watchexec::{
|
use watchexec::{
|
||||||
filter::tagged::{
|
filter::tagged::{
|
||||||
files::{self, FilterFile},
|
files::{self, FilterFile},
|
||||||
Filter, Matcher, Op, Pattern, TaggedFilterer,
|
Filter, Matcher, Op, Pattern, TaggedFilterer,
|
||||||
},
|
},
|
||||||
ignore::IgnoreFile,
|
ignore::IgnoreFile,
|
||||||
|
project::ProjectType,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn tagged(args: &ArgMatches<'static>) -> Result<Arc<TaggedFilterer>> {
|
pub async fn tagged(args: &ArgMatches<'static>) -> Result<Arc<TaggedFilterer>> {
|
||||||
let (project_origin, workdir) = super::common::dirs(args).await?;
|
let (project_origin, workdir) = super::common::dirs(args).await?;
|
||||||
let ignores = super::common::ignores(args, &project_origin).await?;
|
let vcs_types = super::common::vcs_types(&project_origin).await;
|
||||||
|
let ignores = super::common::ignores(args, &vcs_types, &project_origin).await?;
|
||||||
|
|
||||||
let filterer = TaggedFilterer::new(project_origin, workdir.clone())?;
|
let filterer = TaggedFilterer::new(project_origin, workdir.clone())?;
|
||||||
|
|
||||||
|
@ -34,8 +36,10 @@ pub async fn tagged(args: &ArgMatches<'static>) -> Result<Arc<TaggedFilterer>> {
|
||||||
debug!(?filter_files, "resolved command filter files");
|
debug!(?filter_files, "resolved command filter files");
|
||||||
|
|
||||||
if !args.is_present("no-global-filters") {
|
if !args.is_present("no-global-filters") {
|
||||||
// TODO: handle errors
|
let (global_filter_files, errors) = files::from_environment().await;
|
||||||
let (global_filter_files, _errors) = files::from_environment().await;
|
for err in errors {
|
||||||
|
warn!("while discovering project-local filter files: {}", err);
|
||||||
|
}
|
||||||
debug!(?global_filter_files, "discovered global filter files");
|
debug!(?global_filter_files, "discovered global filter files");
|
||||||
filter_files.extend(global_filter_files);
|
filter_files.extend(global_filter_files);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue