diff --git a/cli/src/filterer/globset.rs b/cli/src/filterer/globset.rs index bd1930e4..6d7b54f4 100644 --- a/cli/src/filterer/globset.rs +++ b/cli/src/filterer/globset.rs @@ -13,7 +13,6 @@ use watchexec::{ Event, Tag, }, filter::{globset::GlobsetFilterer, Filterer}, - project::ProjectType, }; pub async fn globset(args: &ArgMatches<'static>) -> Result> { @@ -32,38 +31,17 @@ pub async fn globset(args: &ArgMatches<'static>) -> Result) -> Result> { @@ -69,35 +68,14 @@ pub async fn tagged(args: &ArgMatches<'static>) -> Result> { Filter::from_glob_ignore(None, ".*.kate-swp"), Filter::from_glob_ignore(None, ".*.sw?"), Filter::from_glob_ignore(None, ".*.sw?x"), + Filter::from_glob_ignore(None, ".bzr"), + Filter::from_glob_ignore(None, "_darcs"), + Filter::from_glob_ignore(None, ".fossil-settings"), + Filter::from_glob_ignore(None, ".git"), + Filter::from_glob_ignore(None, ".hg"), + Filter::from_glob_ignore(None, ".pijul"), + Filter::from_glob_ignore(None, ".svn"), ]); - - if vcs_types.contains(&ProjectType::Git) { - filters.push(Filter::from_glob_ignore(None, "/.git")); - } - - if vcs_types.contains(&ProjectType::Mercurial) { - filters.push(Filter::from_glob_ignore(None, "/.hg")); - } - - if vcs_types.contains(&ProjectType::Subversion) { - filters.push(Filter::from_glob_ignore(None, "/.svn")); - } - - if vcs_types.contains(&ProjectType::Bazaar) { - filters.push(Filter::from_glob_ignore(None, "/.bzr")); - } - - if vcs_types.contains(&ProjectType::Darcs) { - filters.push(Filter::from_glob_ignore(None, "/_darcs")); - } - - if vcs_types.contains(&ProjectType::Fossil) { - filters.push(Filter::from_glob_ignore(None, "/.fossil-settings")); - } - - if vcs_types.contains(&ProjectType::Pijul) { - filters.push(Filter::from_glob_ignore(None, "/.pijul")); - } } if args.is_present("no-meta") { diff --git a/doc/watchexec.1 b/doc/watchexec.1 index 57a6dd62..5320e82e 100644 --- a/doc/watchexec.1 +++ b/doc/watchexec.1 @@ -1,13 +1,13 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "WATCHEXEC" "1" "July 2021" "" "" +.TH "WATCHEXEC" "1" "February 2022" "" "" . .SH "NAME" \fBwatchexec\fR \- execute commands when watched files change . .SH "SYNOPSIS" -watchexec [\fB\-\-exts\fR | \fB\-e\fR \fIextensions\fR]\.\.\. [\fB\-\-filter\fR | \fB\-f\fR \fIpattern\fR]\.\.\. [\fB\-\-ignore\fR | \fB\-i\fR \fIpattern\fR]\.\.\. [\fB\-\-watch\fR | \fB\-w\fR \fIpath\fR]\.\.\. [\fB\-\-restart\fR | \fB\-r\fR] [\fB\-\-clear\fR | \fB\-c\fR] [\fB\-\-postpone\fR | \fB\-p\fR] [\fB\-\-force\-poll\fR \fIinterval\fR] [\fB\-\-debounce\fR | \fB\-d\fR \fIinterval\fR] [\fB\-\-no\-vcs\-ignore\fR] [\fB\-\-no\-default\-ignore\fR] [\fB\-\-verbose\fR | \fB\-v\fR] [\fB\-\-changes\-only\fR] [\fB\-\-version\fR | \fB\-V\fR] [\-\-] \fIcommand\fR [\fIargument\fR\.\.\.] +watchexec [\fB\-\-exts\fR | \fB\-e\fR \fIextensions\fR]\.\.\. [\fB\-\-filter\fR | \fB\-f\fR \fIpattern\fR]\.\.\. [\fB\-\-ignore\fR | \fB\-i\fR \fIpattern\fR]\.\.\. [\fB\-\-watch\fR | \fB\-w\fR \fIpath\fR]\.\.\. [\fB\-\-restart\fR | \fB\-r\fR] [\fB\-\-clear\fR | \fB\-c\fR] [\fB\-\-postpone\fR | \fB\-p\fR] [\fB\-\-force\-poll\fR \fIinterval\fR] [\fB\-\-debounce\fR | \fB\-d\fR \fIinterval\fR] [\fB\-\-no\-vcs\-ignore\fR] [\fB\-\-no\-default\-ignore\fR] [\fB\-\-verbose\fR | \fB\-v\fR | \fB\-vv\fR | \fB\-vvv\fR | \fB\-vvvv\fR] [\fB\-\-changes\-only\fR] [\fB\-\-version\fR | \fB\-V\fR] [\-\-] \fIcommand\fR [\fIargument\fR\.\.\.] . .SH "DESCRIPTION" Recursively monitors the current directory for changes, executing the command when a filesystem change is detected\. By default, watchexec uses efficient kernel\-level mechanisms to watch for changes\. @@ -112,19 +112,31 @@ Set the timeout between detected change and command execution, to avoid restarti . .TP \fB\-\-no\-vcs\-ignore\fR -Skip loading of version control system (VCS) ignore files\. By default, watchexec loads \.gitignore files in the current directory (or parent directories) and uses them to populate the ignore list\. +Skip loading of version control system (VCS) ignore files\. By default, watchexec loads \.gitignore, \.hgignore, and other such files in the current directory (or child directories as applicable) and uses them to filter change events\. +. +.TP +\fB\-\-no\-project\-ignore\fR, \fB\-\-no\-ignore\fR (deprecated alias) +Skip loading of project\-local ignore files (include VCS ignore files)\. By default, watchexec loads \.ignore, \.gitignore, \.hgignore, and other such files in the current directory (or child directories as applicable) and uses them to filter change events\. . .TP \fB\-\-no\-default\-ignore\fR -Skip default ignore statements\. By default, watchexec ignores common temporary files for you, for example \fB*\.swp\fR, \fB*\.pyc\fR, and \fB\.DS_Store\fR\. +Skip default ignore statements\. By default, watchexec ignores common temporary files for you, for example \fB*\.swp\fR, \fB*\.pyc\fR, and \fB\.DS_Store\fR, as well as the data directories of known VCS: \fB\.bzr\fR, \fB_darcs\fR, \fB\.fossil\-settings\fR, \fB\.git\fR, \fB\.hg\fR, \fB\.pijul\fR, and \fB\.svn\fR\. . .TP -\fB\-v\fR, \fB\-\-verbose\fR -Prints diagnostic messages to STDERR\. +\fB\-\-no\-global\-ignore\fR +Skip loading of global ignore files\. By default, watchexec loads $HOME/\.gitignore and other such global files and uses them to filter change events\. . .TP -\fB\-\-changes\-only\fR -Prints the paths that have changed as diagnostics to STDERR, but not everything else that \fB\-\-verbose\fR prints\. +\fB\-v\fR, \fB\-\-verbose\fR, \fB\-vv\fR, etc +Prints diagnostic and debugging messages to STDERR\. Increase the amount of \fBv\fRs to get progressively more output: for bug reports use \fBthree\fR, and for deep debugging \fBfour\fR can be helpful\. +. +.TP +\fB\-\-print\-events\fR, \fB\-\-changes\-only\fR (deprecated alias) +Prints the events (changed paths, etc) that have triggered an action to STDERR\. +. +.TP +\fB\-N\fR, \fB\-\-notify\fR +Sends desktop notifications on command start and command end\. . .TP \fB\-V\fR, \fB\-\-version\fR @@ -135,36 +147,99 @@ Print the version of watchexec\. Print a help message\. . .SH "ENVIRONMENT" -Processes started by watchexec have environment variables set describing the modification(s) observed\. Which variable is set depends on how many modifications were observed and/or what type they were\. +In variables that contain lists of paths, the separator is as for the \fB$PATH\fR environment variable (a colon, or semicolon on Windows)\. +. +.SS "Set on child processes" +Processes started by watchexec have environment variables set describing the changes observed\. . .P -If a single file changed (depending on the event type): +\fB$WATCHEXEC_COMMON_PATH\fR is set to the longest common path of all of the below variables, and so should be prepended to each path to obtain the full/real path\. . .IP "\(bu" 4 -\fB$WATCHEXEC_CREATED_PATH\fR, the path of the file that was created +\fB$WATCHEXEC_CREATED_PATH\fR is set when files/folders were created . .IP "\(bu" 4 -\fB$WATCHEXEC_REMOVED_PATH\fR, the path of the file that was removed +\fB$WATCHEXEC_REMOVED_PATH\fR is set when files/folders were removed . .IP "\(bu" 4 -\fB$WATCHEXEC_RENAMED_PATH\fR, the path of the file that was renamed +\fB$WATCHEXEC_RENAMED_PATH\fR is set when files/folders were renamed . .IP "\(bu" 4 -\fB$WATCHEXEC_WRITTEN_PATH\fR, the path of the file that was modified +\fB$WATCHEXEC_WRITTEN_PATH\fR is set when files/folders were modified . .IP "\(bu" 4 -\fB$WATCHEXEC_META_CHANGED_PATH\fR, the path of the file whose metadata changed +\fB$WATCHEXEC_META_CHANGED_PATH\fR is set when files/folders\' metadata were modified +. +.IP "\(bu" 4 +\fB$WATCHEXEC_OTHERWISE_CHANGED_PATH\fR is set for every other kind of pathed event . .IP "" 0 . .P -If multiple files changed: +This can be disabled or limited with \fB\-\-no\-environment\fR (doesn\'t set any of these variables) and \fB\-\-no\-meta\fR (ignores metadata changes)\. +. +.SS "Read upon startup" . .IP "\(bu" 4 -\fB$WATCHEXEC_COMMON_PATH\fR, the longest common path of all of the files that triggered a change +\fB$WATCHEXEC_FILTERER\fR: select the filterer implementation: \fBglobset\fR (default), or \fBtagged\fR (experimental)\. +. +.IP "\(bu" 4 +\fB$WATCHEXEC_IGNORE_FILES\fR: a list of paths to additional ignore files to be loaded\. +. +.IP "\(bu" 4 +\fB$WATCHEXEC_FILTER_FILES\fR: a list of paths to additional "Tagged" filter files to be loaded (when enabled)\. +. +.IP "\(bu" 4 +\fB$RUST_LOG\fR: use for advanced verbose logging configuration\. Refer to tracing\-subscriber for documentation\. . .IP "" 0 . +.SH "FILES" +. +.SS "Supported project ignore files" +. +.IP "\(bu" 4 +Git: \fB\.gitignore\fR at project root and child directories, \fB\.git/info/exclude\fR, and the file pointed to by \fBcore\.excludesFile\fR in \fB\.git/config\fR\. +. +.IP "\(bu" 4 +Mercurial: \fB\.hgignore\fR at project root and child directories\. +. +.IP "\(bu" 4 +Bazaar: \fB\.bzrignore\fR at project root\. +. +.IP "\(bu" 4 +Darcs: \fB_darcs/prefs/boring\fR +. +.IP "\(bu" 4 +Fossil: \fB\.fossil\-settings/ignore\-glob\fR +. +.IP "\(bu" 4 +Ripgrep/Watchexec/generic: \fB\.ignore\fR at project root and child directories\. +. +.IP "" 0 +. +.P +Note that VCS ignore files (Git, Mercurial, Bazaar, Darcs, Fossil) are only used if the corresponding VCS is discovered to be in use for the project/origin\. For example, a \fB\.bzrignore\fR in a Git repository will be discarded\. +. +.SS "Supported global ignore files" +. +.IP "\(bu" 4 +Git (if core\.excludesFile is set): the file at that path +. +.IP "\(bu" 4 +Git (otherwise): the first found of \fB$XDG_CONFIG_HOME/git/ignore\fR, \fB%APPDATA%/\.gitignore\fR, \fB%USERPROFILE%/\.gitignore\fR, \fB$HOME/\.config/git/ignore\fR, \fB$HOME/\.gitignore\fR\. +. +.IP "\(bu" 4 +Bazaar: the first found of \fB%APPDATA%/Bazzar/2\.0/ignore\fR, \fB$HOME/\.bazaar/ignore\fR\. +. +.IP "\(bu" 4 +Watchexec: the first found of \fB$XDG_CONFIG_HOME/watchexec/ignore\fR, \fB%APPDATA%/watchexec/ignore\fR, \fB%USERPROFILE%/\.watchexec/ignore\fR, \fB$HOME/\.watchexec/ignore\fR\. +. +.IP "" 0 +. +.P +Note that like for project files, Git and Bazaar global files will only be used for the corresponding VCS as used in the project\. +. .SH "EXAMPLES" Rebuild a project when source files change: . diff --git a/doc/watchexec.1.html b/doc/watchexec.1.html index 7b9b2231..9e17a493 100644 --- a/doc/watchexec.1.html +++ b/doc/watchexec.1.html @@ -64,6 +64,7 @@ DESCRIPTION OPTIONS ENVIRONMENT + FILES EXAMPLES @@ -80,7 +81,7 @@

SYNOPSIS

-

watchexec [--exts | -e extensions]... [--filter | -f pattern]... [--ignore | -i pattern]... [--watch | -w path]... [--restart | -r] [--clear | -c] [--postpone | -p] [--force-poll interval] [--debounce | -d interval] [--no-vcs-ignore] [--no-default-ignore] [--verbose | -v] [--changes-only] [--version | -V] [--] command [argument...]

+

watchexec [--exts | -e extensions]... [--filter | -f pattern]... [--ignore | -i pattern]... [--watch | -w path]... [--restart | -r] [--clear | -c] [--postpone | -p] [--force-poll interval] [--debounce | -d interval] [--no-vcs-ignore] [--no-default-ignore] [--verbose | -v | -vv | -vvv | -vvvv] [--changes-only] [--version | -V] [--] command [argument...]

DESCRIPTION

@@ -135,10 +136,13 @@
-p, --postpone

Postpone execution of command until the first file modification is detected.

--force-poll interval

Poll for changes every interval ms instead of using system-specific notification mechanisms (such as inotify). This is useful when you are monitoring NFS shares.

-d, --debounce

Set the timeout between detected change and command execution, to avoid restarting too frequently when there are many events; defaults to 100ms.

-
--no-vcs-ignore

Skip loading of version control system (VCS) ignore files. By default, watchexec loads .gitignore files in the current directory (or parent directories) and uses them to populate the ignore list.

-
--no-default-ignore

Skip default ignore statements. By default, watchexec ignores common temporary files for you, for example *.swp, *.pyc, and .DS_Store.

-
-v, --verbose

Prints diagnostic messages to STDERR.

-
--changes-only

Prints the paths that have changed as diagnostics to STDERR, but not everything else that --verbose prints.

+
--no-vcs-ignore

Skip loading of version control system (VCS) ignore files. By default, watchexec loads .gitignore, .hgignore, and other such files in the current directory (or child directories as applicable) and uses them to filter change events.

+
--no-project-ignore, --no-ignore (deprecated alias)

Skip loading of project-local ignore files (include VCS ignore files). By default, watchexec loads .ignore, .gitignore, .hgignore, and other such files in the current directory (or child directories as applicable) and uses them to filter change events.

+
--no-default-ignore

Skip default ignore statements. By default, watchexec ignores common temporary files for you, for example *.swp, *.pyc, and .DS_Store, as well as the data directories of known VCS: .bzr, _darcs, .fossil-settings, .git, .hg, .pijul, and .svn.

+
--no-global-ignore

Skip loading of global ignore files. By default, watchexec loads $HOME/.gitignore and other such global files and uses them to filter change events.

+
-v, --verbose, -vv, etc

Prints diagnostic and debugging messages to STDERR. Increase the amount of vs to get progressively more output: for bug reports use three, and for deep debugging four can be helpful.

+
--print-events, --changes-only (deprecated alias)

Prints the events (changed paths, etc) that have triggered an action to STDERR.

+
-N, --notify

Sends desktop notifications on command start and command end.

-V, --version

Print the version of watchexec.

-h, --help

Print a help message.

@@ -146,26 +150,64 @@

ENVIRONMENT

-

Processes started by watchexec have environment variables set describing the modification(s) observed. Which variable is set depends on how many modifications were observed and/or what type they were.

+

In variables that contain lists of paths, the separator is as for the $PATH environment variable (a colon, or semicolon on Windows).

-

If a single file changed (depending on the event type):

+

Set on child processes

+ +

Processes started by watchexec have environment variables set describing the changes observed.

+ +

$WATCHEXEC_COMMON_PATH is set to the longest common path of all of the below variables, and so should be prepended to each path to obtain the full/real path.

    -
  • $WATCHEXEC_CREATED_PATH, the path of the file that was created
  • -
  • $WATCHEXEC_REMOVED_PATH, the path of the file that was removed
  • -
  • $WATCHEXEC_RENAMED_PATH, the path of the file that was renamed
  • -
  • $WATCHEXEC_WRITTEN_PATH, the path of the file that was modified
  • -
  • $WATCHEXEC_META_CHANGED_PATH, the path of the file whose metadata changed
  • +
  • $WATCHEXEC_CREATED_PATH is set when files/folders were created
  • +
  • $WATCHEXEC_REMOVED_PATH is set when files/folders were removed
  • +
  • $WATCHEXEC_RENAMED_PATH is set when files/folders were renamed
  • +
  • $WATCHEXEC_WRITTEN_PATH is set when files/folders were modified
  • +
  • $WATCHEXEC_META_CHANGED_PATH is set when files/folders' metadata were modified
  • +
  • $WATCHEXEC_OTHERWISE_CHANGED_PATH is set for every other kind of pathed event
-

If multiple files changed:

+

This can be disabled or limited with --no-environment (doesn't set any of these variables) and --no-meta (ignores metadata changes).

+ +

Read upon startup

    -
  • $WATCHEXEC_COMMON_PATH, the longest common path of all of the files that triggered a change
  • +
  • $WATCHEXEC_FILTERER: select the filterer implementation: globset (default), or tagged (experimental).
  • +
  • $WATCHEXEC_IGNORE_FILES: a list of paths to additional ignore files to be loaded.
  • +
  • $WATCHEXEC_FILTER_FILES: a list of paths to additional "Tagged" filter files to be loaded (when enabled).
  • +
  • $RUST_LOG: use for advanced verbose logging configuration. Refer to tracing-subscriber for documentation.
+

FILES

+ +

Supported project ignore files

+ +
    +
  • Git: .gitignore at project root and child directories, .git/info/exclude, and the file pointed to by core.excludesFile in .git/config.
  • +
  • Mercurial: .hgignore at project root and child directories.
  • +
  • Bazaar: .bzrignore at project root.
  • +
  • Darcs: _darcs/prefs/boring
  • +
  • Fossil: .fossil-settings/ignore-glob
  • +
  • Ripgrep/Watchexec/generic: .ignore at project root and child directories.
  • +
+ + +

Note that VCS ignore files (Git, Mercurial, Bazaar, Darcs, Fossil) are only used if the corresponding VCS is discovered to be in use for the project/origin. For example, a .bzrignore in a Git repository will be discarded.

+ +

Supported global ignore files

+ +
    +
  • Git (if core.excludesFile is set): the file at that path
  • +
  • Git (otherwise): the first found of $XDG_CONFIG_HOME/git/ignore, %APPDATA%/.gitignore, %USERPROFILE%/.gitignore, $HOME/.config/git/ignore, $HOME/.gitignore.
  • +
  • Bazaar: the first found of %APPDATA%/Bazzar/2.0/ignore, $HOME/.bazaar/ignore.
  • +
  • Watchexec: the first found of $XDG_CONFIG_HOME/watchexec/ignore, %APPDATA%/watchexec/ignore, %USERPROFILE%/.watchexec/ignore, $HOME/.watchexec/ignore.
  • +
+ + +

Note that like for project files, Git and Bazaar global files will only be used for the corresponding VCS as used in the project.

+

EXAMPLES

Rebuild a project when source files change:

@@ -221,7 +263,7 @@
  1. -
  2. July 2021
  3. +
  4. February 2022
  5. watchexec(1)
diff --git a/doc/watchexec.1.ronn b/doc/watchexec.1.ronn index 1de92b96..fe05fd2d 100644 --- a/doc/watchexec.1.ronn +++ b/doc/watchexec.1.ronn @@ -88,7 +88,7 @@ Skip loading of version control system (VCS) ignore files. By default, watchexec Skip loading of project-local ignore files (include VCS ignore files). By default, watchexec loads .ignore, .gitignore, .hgignore, and other such files in the current directory (or child directories as applicable) and uses them to filter change events. * `--no-default-ignore`: -Skip default ignore statements. By default, watchexec ignores common temporary files for you, for example `*.swp`, `*.pyc`, and `.DS_Store`, as well as the data directories of the VCS system in use (e.g. `.git` if you use Git, `.svn` for Subversion, etc). +Skip default ignore statements. By default, watchexec ignores common temporary files for you, for example `*.swp`, `*.pyc`, and `.DS_Store`, as well as the data directories of known VCS: `.bzr`, `_darcs`, `.fossil-settings`, `.git`, `.hg`, `.pijul`, and `.svn`. * `--no-global-ignore`: Skip loading of global ignore files. By default, watchexec loads $HOME/.gitignore and other such global files and uses them to filter change events.