Reorganise the ignore mod for brevity
This commit is contained in:
parent
5f43a6eae8
commit
2c840f4a2d
|
@ -9,7 +9,7 @@ use dunce::canonicalize;
|
|||
use miette::{IntoDiagnostic, Result};
|
||||
use tracing::{debug, warn};
|
||||
use watchexec::{
|
||||
ignore::{self, files::IgnoreFile},
|
||||
ignore::{self, IgnoreFile},
|
||||
paths::common_prefix,
|
||||
project::{self, ProjectType},
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ pub async fn ignores(args: &ArgMatches<'static>, origin: &Path) -> Result<Vec<Ig
|
|||
.collect::<Vec<_>>();
|
||||
debug!(?vcs_types, "resolved vcs types");
|
||||
|
||||
let (mut ignores, _errors) = ignore::files::from_origin(origin).await;
|
||||
let (mut ignores, _errors) = ignore::from_origin(origin).await;
|
||||
// TODO: handle errors
|
||||
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");
|
||||
}
|
||||
|
||||
let (mut global_ignores, _errors) = ignore::files::from_environment().await;
|
||||
let (mut global_ignores, _errors) = ignore::from_environment().await;
|
||||
// TODO: handle errors
|
||||
debug!(?global_ignores, "discovered ignore files from environment");
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use watchexec::{
|
|||
files::{self, FilterFile},
|
||||
Filter, Matcher, Op, Pattern, TaggedFilterer,
|
||||
},
|
||||
ignore::files::IgnoreFile,
|
||||
ignore::IgnoreFile,
|
||||
};
|
||||
|
||||
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::event::{Event, FileType};
|
||||
use crate::filter::Filterer;
|
||||
use crate::ignore::files::IgnoreFile;
|
||||
use crate::ignore::IgnoreFile;
|
||||
|
||||
/// A path-only filterer based on globsets.
|
||||
///
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::error::RuntimeError;
|
|||
use crate::event::{Event, FileType, ProcessEnd, Tag};
|
||||
use crate::filter::tagged::error::TaggedFiltererError;
|
||||
use crate::filter::Filterer;
|
||||
use crate::ignore::files::IgnoreFile;
|
||||
use crate::ignore::IgnoreFile;
|
||||
use crate::signal::process::SubSignal;
|
||||
use crate::signal::source::MainSignal;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::{
|
|||
|
||||
use tokio::fs::read_to_string;
|
||||
|
||||
use crate::ignore::files::{discover_file, IgnoreFile};
|
||||
use crate::ignore::{discover_file, IgnoreFile};
|
||||
|
||||
use super::{error::TaggedFiltererError, Filter};
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
//! Ignore files: find them, parse them, interpret them.
|
||||
|
||||
#[doc(inline)]
|
||||
pub use filter::Filter;
|
||||
|
||||
pub mod files;
|
||||
pub use files::*;
|
||||
#[doc(inline)]
|
||||
pub use filter::*;
|
||||
|
||||
mod files;
|
||||
mod filter;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
//! Find ignore files, like `.gitignore`, `.ignore`, and others.
|
||||
|
||||
use std::{
|
||||
env,
|
||||
io::{Error, ErrorKind},
|
||||
|
|
|
@ -25,13 +25,13 @@ use super::files::IgnoreFile;
|
|||
/// It implements [`Filterer`] so it can be used directly in another filterer; it is not designed to
|
||||
/// be used as a standalone filterer.
|
||||
#[derive(Debug)]
|
||||
pub struct Filter {
|
||||
pub struct IgnoreFilterer {
|
||||
origin: PathBuf,
|
||||
builder: Option<GitignoreBuilder>,
|
||||
compiled: Gitignore,
|
||||
}
|
||||
|
||||
impl Filter {
|
||||
impl IgnoreFilterer {
|
||||
/// Read ignore files from disk and load them for filtering.
|
||||
pub async fn new(origin: impl AsRef<Path>, files: &[IgnoreFile]) -> Result<Self, RuntimeError> {
|
||||
let (files_contents, errors): (Vec<_>, Vec<_>) = files
|
||||
|
@ -200,7 +200,7 @@ impl Filter {
|
|||
}
|
||||
}
|
||||
|
||||
impl Filterer for Filter {
|
||||
impl Filterer for IgnoreFilterer {
|
||||
/// Filter an event.
|
||||
///
|
||||
/// This implementation never errors. It returns `Ok(false)` if the event is ignored according
|
||||
|
|
Loading…
Reference in New Issue