mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-14 08:11:11 +01:00
Add default ignores
This commit is contained in:
parent
b5da4e31ba
commit
4dbb924977
3 changed files with 40 additions and 3 deletions
|
@ -102,7 +102,7 @@ pub fn get_args(tagged_filterer: bool) -> Result<ArgMatches<'static>> {
|
|||
.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"))
|
||||
|
|
|
@ -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<Arc<WatchexecFilterer
|
|||
let ignorefiles = super::common::ignores(args, &project_origin).await?;
|
||||
|
||||
let mut ignores = Vec::new();
|
||||
|
||||
if !args.is_present("no-default-ignore") {
|
||||
ignores.extend([
|
||||
(format!("**{s}.DS_Store", s = MAIN_SEPARATOR), None),
|
||||
(String::from("*.py[co]"), None),
|
||||
(String::from("#*#"), None),
|
||||
(String::from(".#*"), None),
|
||||
(String::from(".*.kate-swp"), None),
|
||||
(String::from(".*.sw?"), None),
|
||||
(String::from(".*.sw?x"), None),
|
||||
(format!("**{s}.git{s}**", s = MAIN_SEPARATOR), None),
|
||||
(format!("**{s}.hg{s}**", s = MAIN_SEPARATOR), None),
|
||||
(format!("**{s}.svn{s}**", s = MAIN_SEPARATOR), None),
|
||||
]);
|
||||
}
|
||||
|
||||
for ignore in ignorefiles {
|
||||
ignores.extend(GlobsetFilterer::list_from_ignore_file(&ignore).await?);
|
||||
}
|
||||
|
@ -40,6 +58,7 @@ pub async fn globset(args: &ArgMatches<'static>) -> Result<Arc<WatchexecFilterer
|
|||
.map(|s| s.split(b','))
|
||||
.flatten();
|
||||
|
||||
debug!(filters=%filters.len(), ignores=%ignores.len(), "vecs lengths");
|
||||
Ok(Arc::new(WatchexecFilterer {
|
||||
inner: GlobsetFilterer::new(project_origin, filters, ignores, exts).into_diagnostic()?,
|
||||
no_meta: args.is_present("no-meta"),
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
use clap::ArgMatches;
|
||||
use futures::future::try_join_all;
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use tracing::debug;
|
||||
use tracing::{debug, trace};
|
||||
use watchexec::{
|
||||
filter::tagged::{
|
||||
files::{self, FilterFile},
|
||||
|
@ -56,6 +56,23 @@ pub async fn tagged(args: &ArgMatches<'static>) -> Result<Arc<TaggedFilterer>> {
|
|||
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<Arc<TaggedFilterer>> {
|
|||
});
|
||||
}
|
||||
|
||||
debug!(?filters, "parsed filters");
|
||||
debug!(filters=%filters.len(), "parsed filters");
|
||||
trace!(?filters, "all filters");
|
||||
filterer.add_filters(&filters).await?;
|
||||
|
||||
Ok(filterer)
|
||||
|
|
Loading…
Reference in a new issue