Move ignore_files one level deeper
in preparation for new ignore functionality
This commit is contained in:
parent
1c99546071
commit
6a541e5f27
|
@ -3,11 +3,12 @@ use std::convert::Infallible;
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use miette::Result;
|
use miette::Result;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use watchexec::{config::InitConfig, handler::SyncFnHandler, error::RuntimeError};
|
use watchexec::{config::InitConfig, error::RuntimeError, handler::SyncFnHandler};
|
||||||
|
|
||||||
pub fn init(_args: &ArgMatches<'static>) -> Result<InitConfig> {
|
pub fn init(_args: &ArgMatches<'static>) -> Result<InitConfig> {
|
||||||
let mut config = InitConfig::default();
|
let mut config = InitConfig::default();
|
||||||
config.on_error(SyncFnHandler::from(|data| -> std::result::Result<(), Infallible> {
|
config.on_error(SyncFnHandler::from(
|
||||||
|
|data| -> std::result::Result<(), Infallible> {
|
||||||
if let RuntimeError::IoError(_) = data {
|
if let RuntimeError::IoError(_) = data {
|
||||||
// these are often spurious, so condemn them to -v only
|
// these are often spurious, so condemn them to -v only
|
||||||
error!("{}", data);
|
error!("{}", data);
|
||||||
|
@ -21,7 +22,8 @@ pub fn init(_args: &ArgMatches<'static>) -> Result<InitConfig> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}));
|
},
|
||||||
|
));
|
||||||
|
|
||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use dunce::canonicalize;
|
||||||
use miette::{IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
use watchexec::{
|
use watchexec::{
|
||||||
ignore_files::{self, IgnoreFile},
|
ignore::{self, files::IgnoreFile},
|
||||||
paths::common_prefix,
|
paths::common_prefix,
|
||||||
project::{self, ProjectType},
|
project::{self, ProjectType},
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,7 @@ pub async fn ignores(args: &ArgMatches<'static>, origin: &Path) -> Result<Vec<Ig
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
debug!(?vcs_types, "resolved vcs types");
|
debug!(?vcs_types, "resolved vcs types");
|
||||||
|
|
||||||
let (mut ignores, _errors) = ignore_files::from_origin(origin).await;
|
let (mut ignores, _errors) = ignore::files::from_origin(origin).await;
|
||||||
// TODO: handle errors
|
// TODO: handle errors
|
||||||
debug!(?ignores, "discovered ignore files from project origin");
|
debug!(?ignores, "discovered ignore files from project origin");
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ 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_files::from_environment().await;
|
let (mut global_ignores, _errors) = ignore::files::from_environment().await;
|
||||||
// TODO: handle errors
|
// TODO: handle errors
|
||||||
debug!(?global_ignores, "discovered ignore files from environment");
|
debug!(?global_ignores, "discovered ignore files from environment");
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use watchexec::{
|
||||||
files::{self, FilterFile},
|
files::{self, FilterFile},
|
||||||
Filter, Matcher, Op, Pattern, TaggedFilterer,
|
Filter, Matcher, Op, Pattern, TaggedFilterer,
|
||||||
},
|
},
|
||||||
ignore_files::IgnoreFile,
|
ignore::files::IgnoreFile,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn tagged(args: &ArgMatches<'static>) -> Result<Arc<TaggedFilterer>> {
|
pub async fn tagged(args: &ArgMatches<'static>) -> Result<Arc<TaggedFilterer>> {
|
||||||
|
|
|
@ -10,7 +10,7 @@ use tracing::{debug, trace, trace_span};
|
||||||
use crate::error::RuntimeError;
|
use crate::error::RuntimeError;
|
||||||
use crate::event::{Event, FileType};
|
use crate::event::{Event, FileType};
|
||||||
use crate::filter::Filterer;
|
use crate::filter::Filterer;
|
||||||
use crate::ignore_files::IgnoreFile;
|
use crate::ignore::files::IgnoreFile;
|
||||||
|
|
||||||
/// A path-only filterer based on globsets.
|
/// A path-only filterer based on globsets.
|
||||||
///
|
///
|
||||||
|
|
|
@ -16,7 +16,7 @@ use crate::error::RuntimeError;
|
||||||
use crate::event::{Event, FileType, ProcessEnd, Tag};
|
use crate::event::{Event, FileType, ProcessEnd, Tag};
|
||||||
use crate::filter::tagged::error::TaggedFiltererError;
|
use crate::filter::tagged::error::TaggedFiltererError;
|
||||||
use crate::filter::Filterer;
|
use crate::filter::Filterer;
|
||||||
use crate::ignore_files::IgnoreFile;
|
use crate::ignore::files::IgnoreFile;
|
||||||
use crate::signal::process::SubSignal;
|
use crate::signal::process::SubSignal;
|
||||||
use crate::signal::source::MainSignal;
|
use crate::signal::source::MainSignal;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::{
|
||||||
|
|
||||||
use tokio::fs::read_to_string;
|
use tokio::fs::read_to_string;
|
||||||
|
|
||||||
use crate::ignore_files::{discover_file, IgnoreFile};
|
use crate::ignore::files::{discover_file, IgnoreFile};
|
||||||
|
|
||||||
use super::{error::TaggedFiltererError, Filter};
|
use super::{error::TaggedFiltererError, Filter};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
//! Ignore files: find them, parse them, interpret them.
|
||||||
|
|
||||||
|
pub mod files;
|
|
@ -282,7 +282,7 @@ pub(crate) async fn discover_file(
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
trace!("found nothing");
|
trace!("found nothing");
|
||||||
false
|
false
|
||||||
},
|
}
|
||||||
Ok(Some(path)) => {
|
Ok(Some(path)) => {
|
||||||
trace!(?path, "found a file");
|
trace!(?path, "found a file");
|
||||||
files.push(IgnoreFile {
|
files.push(IgnoreFile {
|
|
@ -104,7 +104,7 @@ pub mod error;
|
||||||
pub mod event;
|
pub mod event;
|
||||||
pub mod filter;
|
pub mod filter;
|
||||||
pub mod fs;
|
pub mod fs;
|
||||||
pub mod ignore_files;
|
pub mod ignore;
|
||||||
pub mod paths;
|
pub mod paths;
|
||||||
pub mod project;
|
pub mod project;
|
||||||
pub mod signal;
|
pub mod signal;
|
||||||
|
|
|
@ -15,7 +15,7 @@ use watchexec::{
|
||||||
tagged::{files::FilterFile, Filter, Matcher, Op, Pattern, TaggedFilterer},
|
tagged::{files::FilterFile, Filter, Matcher, Op, Pattern, TaggedFilterer},
|
||||||
Filterer,
|
Filterer,
|
||||||
},
|
},
|
||||||
ignore_files::IgnoreFile,
|
ignore::files::IgnoreFile,
|
||||||
project::ProjectType,
|
project::ProjectType,
|
||||||
signal::source::MainSignal,
|
signal::source::MainSignal,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue