Commit Graph

361 Commits

Author SHA1 Message Date
Félix Saparelli 446a8d95a7 Replace event queue with a priority queue (#302)
Solves several issues, generally through delivering signals before filesystem events, preventing situations where an overwhelming amount of events makes it impossible to quit.

Does _not_ solve the problem of a queue full of lower-priority events not accepting an urgent message, but that's a rarer issue that's more complicated to overcome.

Changes the Filterer trait: adds Priority to `check_event()`

Makes some events unfilterable (Urgent priority): SIGINT, SIGTERM, and CTRL_C to the main process. These still need to be handled by `on_action` to do anything, but cannot be stopped before reaching that.
2022-06-11 06:43:11 +00:00
Félix Saparelli 62e79fbf7a Add log feature to tracing (#300) 2022-06-07 12:15:17 +00:00
Félix Saparelli 557efab1c4 Document the format of the globset tuple arguments (#298) 2022-06-07 11:46:07 +00:00
Félix Saparelli e215e2c09f Add folder/file ignore and filter tests to globset (#299) 2022-06-07 11:25:50 +00:00
Félix Saparelli ec26a99b7d Fix watchexec example in docs found in #295 (#297) 2022-06-07 09:19:16 +00:00
Félix Saparelli 009ef2356f Deny 2018 idioms 2022-04-13 22:59:43 +12:00
Félix Saparelli 98348be8b5 lib: v2.0.0-pre.14 2022-04-04 11:47:36 +12:00
David Calavera 20597802ad
Remove git2 as a dependency (#267)
This dependency cannot be sent between threads.
Instead use git-config which is a pure rust implementation to read git config files.

Uses the builtin values::Path struct to extract ignore paths.
It takes care of all the corner cases with how git interprets paths.
2022-04-04 11:43:30 +12:00
Félix Saparelli 3969264e91 lib: v2.0.0-pre.13 2022-03-18 15:00:02 +13:00
Félix Saparelli 07bf2523b6 Revert mac to fsevents 2022-03-18 14:08:59 +13:00
Félix Saparelli 29dcd418ba lib: v2.0.0-pre.12 2022-03-16 16:10:33 +13:00
Félix Saparelli e5731abde0 Use exact version reqs for prereleases
I did not realise that Cargo considers -pre.1 and -pre.2 to be
compatible, so the latest Notify prerelease broke all existing
releases, and whenever I release a new lib it may break all CLI
versions if the API changes.
2022-03-16 16:02:29 +13:00
Félix Saparelli 17edfe663b Add library version to debug log 2022-03-15 23:25:54 +13:00
Félix Saparelli 465895ddec Upgrade notify 2022-03-14 12:57:49 +13:00
Félix Saparelli 5e6adabf8d Use kqueue on mac 2022-03-14 12:50:46 +13:00
Félix Saparelli 9ff5875327 lib: v2.0.0-pre.11 2022-03-07 20:59:47 +13:00
Félix Saparelli 72100217e8 Allow */foo filters to match foo (compat)
This is buggy behaviour that exists in <=1.17, and this patch restores it*

Per gitignore rules, this glob:

    */somefile

Will match:

    foo/somefile
    bar/somefile

But not:

    somefile

However, so far we’ve accepted this. As this is a breaking change, this patch
introduces a hack which lets us accept this behaviour, but clearly marks it as
a compatibility exception. In 2.0, this will be gone.

Fixes #258

* It only restores it on unices, because the behaviour cannot be restored in
  any reasonable manner on Windows. Ah well. It's not for long anyway.
2022-03-07 20:33:29 +13:00
Félix Saparelli 03aef187bd Let --exts and --filter work together
These two options are meant to work together: they are a union of filters
rather than competing. Thus:

    --exts toml,py --filter Gemfile

will match all of:

    foo.toml
    bar.py
    Gemfile

rather than matching no files at all because Gemfile doesn’t have an extension.

Fixes #259
2022-02-22 02:26:46 +13:00
Félix Saparelli 4af6865ef0 Add broken tests for regressions
See #258 and #259
2022-02-12 22:39:40 +13:00
Félix Saparelli 93da1ce780 Carry help through elevated errors properly
This might show the help text twice actually. Let's see...
2022-02-12 20:05:19 +13:00
Félix Saparelli b77da446d8
Split known create errors to get proper help text 2022-02-12 19:49:02 +13:00
Félix Saparelli 3b64a41d80
Split fs watcher errors into their own enum 2022-02-12 19:37:24 +13:00
Félix Saparelli 797a7fc708 Setup cargo-release 2022-02-10 01:40:32 +13:00
Félix Saparelli bdcbe5ca3c lib: v2.0.0-pre.10 2022-02-07 17:18:21 +13:00
Félix Saparelli 965030b47b Add help text to FsWatcherCreate on Linux
See #251
2022-02-07 17:15:27 +13:00
Félix Saparelli e40744f033 Elevate FsWatcherCreate errors to critical
See #251
2022-02-07 17:15:27 +13:00
Félix Saparelli 427e4a0d08 Change on_error to let the handler raise a CriticalError 2022-02-07 17:15:27 +13:00
Félix Saparelli a890b0c916 Deduplicate paths in summarise_events_to_env
Fixes #253
2022-01-31 02:14:28 +13:00
Félix Saparelli bc50c198b3 lib: v2.0.0-pre.9 2022-01-31 00:35:27 +13:00
Félix Saparelli d7a305fc4c
Only run one outcome worker at a time 2022-01-31 00:05:43 +13:00
Félix Saparelli 2a9ee4de0b
Add detailed logging to process holder 2022-01-31 00:05:10 +13:00
Félix Saparelli 9a736c5eb9
Use newly &self Supervisor.wait to drop wait loop 2022-01-31 00:04:56 +13:00
Félix Saparelli 995d38078e
Use a tokio::watch in the supervisor to avoid races 2022-01-31 00:00:51 +13:00
Félix Saparelli 3e942c4d19
Double-check the ongoing atomic 2022-01-30 22:29:33 +13:00
Félix Saparelli fdf4dcd13e
Provide opportunities for process holder to be queried concurrently to a wait() 2022-01-29 04:14:51 +13:00
Félix Saparelli 12ef0411f8
Don't log an error from outcome worker on graceful exit 2022-01-29 04:13:28 +13:00
Félix Saparelli 328700dd72
Stop holding supervisor handle 2022-01-29 04:13:08 +13:00
Félix Saparelli c74eab5e91 Split up action in mods 2022-01-29 02:39:06 +13:00
Félix Saparelli cc0c0be45a
Save a pointer by passing around an Arc<[T]> instead of Arc<Vec<T>> 2022-01-29 02:17:23 +13:00
Félix Saparelli 22f081a47b Spawn outcome apply separately from action loop 2022-01-29 02:08:34 +13:00
Félix Saparelli 10b31a0269 Wrap Supervisor in a RwLock 2022-01-29 02:08:34 +13:00
Félix Saparelli a651d149b0 Replace AtomicTakes with HandleLocks in action 2022-01-29 02:08:34 +13:00
Félix Saparelli b8ffa0c38a Formatting 2022-01-29 02:08:34 +13:00
Félix Saparelli 9845d48464 Add HandlerLock wrapper
This lets a Handler be shared (via a Tokio mutex)
2022-01-29 02:08:34 +13:00
Félix Saparelli d9006a240d Remove keep_* config methods 2022-01-29 02:08:25 +13:00
Félix Saparelli c444895593
Move swaplock to the root 2022-01-28 23:32:54 +13:00
Félix Saparelli 18a2b204e2 Hide io::errors when "waiting on process group" 2022-01-27 10:48:24 +13:00
Félix Saparelli fc40336db7 lib: v2.0.0-pre.8 2022-01-26 10:01:15 +13:00
Félix Saparelli a6c997f470
globset: Always pass non-path events (#248) 2022-01-26 09:59:53 +13:00
Félix Saparelli f6a3b76d92 lib: v2.0.0-pre.7 2022-01-26 02:33:28 +13:00