diff --git a/cli/src/args.rs b/cli/src/args.rs index 744757fd..47ed5915 100644 --- a/cli/src/args.rs +++ b/cli/src/args.rs @@ -102,7 +102,7 @@ pub fn get_args(tagged_filterer: bool) -> Result> { .help_heading(Some(OPTSET_FILTERING)) .help("Skip auto-loading of project ignore files (.gitignore, .ignore, etc)") .long("no-ignore")) - .arg(Arg::with_name("no-default-ignore") // TODO + .arg(Arg::with_name("no-default-ignore") .help_heading(Some(OPTSET_FILTERING)) .help("Skip auto-ignoring of commonly ignored globs") .long("no-default-ignore")) diff --git a/cli/src/filterer/globset.rs b/cli/src/filterer/globset.rs index 38ca25c6..0a3b3670 100644 --- a/cli/src/filterer/globset.rs +++ b/cli/src/filterer/globset.rs @@ -1,10 +1,12 @@ use std::{ ffi::{OsStr, OsString}, + path::MAIN_SEPARATOR, sync::Arc, }; use clap::ArgMatches; use miette::{IntoDiagnostic, Result}; +use tracing::debug; use watchexec::{ error::RuntimeError, event::{ @@ -19,6 +21,22 @@ pub async fn globset(args: &ArgMatches<'static>) -> Result) -> Result) -> Result> { filters.push(filter); } + if !args.is_present("no-default-ignore") { + filters.extend([ + Filter::from_glob_ignore(None, ".DS_Store/"), + Filter::from_glob_ignore(None, ".git/"), + Filter::from_glob_ignore(None, ".hg/"), + Filter::from_glob_ignore(None, ".svn/"), + Filter::from_glob_ignore(None, "_darcs/"), + Filter::from_glob_ignore(None, ".fossil-settings/"), + Filter::from_glob_ignore(None, "*.py[co]"), + Filter::from_glob_ignore(None, "#*#"), + Filter::from_glob_ignore(None, ".#*"), + Filter::from_glob_ignore(None, ".*.kate-swp"), + Filter::from_glob_ignore(None, ".*.sw?"), + Filter::from_glob_ignore(None, ".*.sw?x"), + ]); + } + if args.is_present("no-meta") { filters.push(Filter { in_path: Some(workdir.clone()), @@ -66,7 +83,8 @@ pub async fn tagged(args: &ArgMatches<'static>) -> Result> { }); } - debug!(?filters, "parsed filters"); + debug!(filters=%filters.len(), "parsed filters"); + trace!(?filters, "all filters"); filterer.add_filters(&filters).await?; Ok(filterer)