mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-28 22:21:33 +02:00
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))
|
||||
}
|
||||
|
||||
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)
|
||||
.await
|
||||
.into_iter()
|
||||
.filter(|pt| pt.is_vcs())
|
||||
.collect::<Vec<_>>();
|
||||
debug!(?vcs_types, "resolved vcs types");
|
||||
vcs_types
|
||||
}
|
||||
|
||||
let (mut ignores, _errors) = ignore::from_origin(origin).await;
|
||||
// TODO: handle errors
|
||||
pub async fn ignores(
|
||||
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");
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
let (mut global_ignores, _errors) = ignore::from_environment().await;
|
||||
// TODO: handle errors
|
||||
let (mut global_ignores, errors) = ignore::from_environment().await;
|
||||
for err in errors {
|
||||
warn!("while discovering global ignore files: {}", err);
|
||||
}
|
||||
debug!(?global_ignores, "discovered ignore files from environment");
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
// TODO: --no-default-ignore (whatever that was)
|
||||
|
||||
Ok(ignores)
|
||||
}
|
||||
|
@ -3,18 +3,20 @@ use std::sync::Arc;
|
||||
use clap::ArgMatches;
|
||||
use futures::future::try_join_all;
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use tracing::{debug, trace};
|
||||
use tracing::{debug, trace, warn};
|
||||
use watchexec::{
|
||||
filter::tagged::{
|
||||
files::{self, FilterFile},
|
||||
Filter, Matcher, Op, Pattern, TaggedFilterer,
|
||||
},
|
||||
ignore::IgnoreFile,
|
||||
project::ProjectType,
|
||||
};
|
||||
|
||||
pub async fn tagged(args: &ArgMatches<'static>) -> Result<Arc<TaggedFilterer>> {
|
||||
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())?;
|
||||
|
||||
@ -34,8 +36,10 @@ pub async fn tagged(args: &ArgMatches<'static>) -> Result<Arc<TaggedFilterer>> {
|
||||
debug!(?filter_files, "resolved command filter files");
|
||||
|
||||
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");
|
||||
filter_files.extend(global_filter_files);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user