Skip to content

fix(watch): forward --ignore, --ignore-file, and --print-events to watchexec - #10629

Merged
jdx merged 1 commit into
jdx:mainfrom
JamBalaya56562:fix-watch-ignore-flags
Jun 26, 2026
Merged

jdx merged 1 commit into
jdx:mainfrom
JamBalaya56562:fix-watch-ignore-flags

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

mise watch --ignore 'spec/**/*.rb' ... has no effect — files matching the
pattern still trigger a restart (reported in discussion #7776).

mise watch is not a transparent pass-through to watchexec. It declares the
watchexec flags itself (#[clap(flatten)] watchexec: WatchexecArgs), parses
them, then rebuilds a fresh watchexec ... -- mise run <task> command line
in Watch::run(). Every flag has to be explicitly re-emitted there, and three
were parsed but never forwarded:

  • --ignore → WatchexecArgs::ignore_patterns
  • --ignore-file → WatchexecArgs::ignore_files
  • --print-events → WatchexecArgs::print_events

The reporter's own mise watch -v debug log confirms it: the constructed
watchexec --restart --exts .rb -- mise run ... line contains --exts /
--restart (which have forwarding branches) but not --ignore.

Note: the existing --ignore push only emits the auto-derived ignores
computed from task sources (merge_watch_patterns), not the user's
ignore_patterns — a name collision that hid the missing forwarding.

Fix

Add the three missing forwarding branches in Watch::run(), matching the
existing flag-forwarding style and the earlier #10392 (--wrap-process) fix for
the same class of bug. The user's --ignore patterns are emitted as an
additional --ignore occurrence; watchexec unions repeated --ignore flags, so
they combine with the source-derived ignores rather than clobbering them (the
existing auto-ignore block is untouched).

Scope is deliberately limited to the three flags named in the discussion to keep
the change minimal; other unforwarded WatchexecArgs flags are out of scope.

Test

Adds e2e/cli/test_watch_ignore, which runs mise watch with the three flags
and asserts they appear on the constructed watchexec command line (the
$ watchexec ... line mise logs under MISE_DEBUG=1).

Resolves the issue reported in discussion #7776.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • mise watch now properly forwards user-specified watch filtering and debug options to the underlying watcher, including --ignore patterns, --ignore-file, and --print-events.
    • Improved behavior when combining these flags together.
  • Tests
    • Added an end-to-end regression test covering correct argument forwarding for --ignore, --ignore-file, and --print-events.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: ce662f9c-acef-44f9-ab8d-cccd10b15a1c

📥 Commits

Reviewing files that changed from the base of the PR and between 1564137 and e974731.

📒 Files selected for processing (2)
  • e2e/cli/test_watch_ignore
  • src/cli/watch.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/cli/watch.rs
  • e2e/cli/test_watch_ignore

📝 Walkthrough

Walkthrough

mise watch now forwards --ignore, --ignore-file, and --print-events to watchexec. A new e2e regression test runs the watch command in debug mode and checks the logged spawned command includes those flags.

Changes

Watch flag forwarding

Layer / File(s) Summary
Forward flags to watchexec
src/cli/watch.rs, e2e/cli/test_watch_ignore
Watch::run appends forwarded ignore and print-event arguments to the watchexec invocation, and the regression test checks the debug output includes them.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • jdx/mise#10392: Also updates src/cli/watch.rs to forward an additional mise watch option into the constructed watchexec command line.

Poem

🐇 I hopped through the watch command line,
With ignores and events that now align.
watchexec sings what mise conveys,
In debug-lit logs, the trail now stays.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: forwarding the missing watchexec flags from watch.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Three WatchexecArgs fields — ignore_patterns, ignore_files, and print_events — were parsed by mise watch but never re-emitted onto the watchexec command line that Watch::run() builds, causing --ignore, --ignore-file, and --print-events to silently have no effect (issue #7776).

  • Adds three forwarding blocks in Watch::run() that emit --ignore <pattern>, --ignore-file <path>, and --print-events to the args list, following the same style as every other forwarded flag; the new user-supplied ignores are pushed before the auto-derived source ignores, which is correct because watchexec unions repeated --ignore occurrences.
  • Adds an e2e regression test (e2e/cli/test_watch_ignore) that anchors its poll loop on the exact $ watchexec debug prefix to avoid false-positive matches on earlier tool-resolution log lines, then asserts all three flags appear in the captured output.

Confidence Score: 5/5

Safe to merge — the change is a minimal, targeted addition of three missing arg-forwarding blocks, each following a well-established pattern already in the file.

The fix is mechanical: three missing forwarding branches added in the correct location, matching every other flag-forwarding block in the function. The watchexec union semantics for repeated --ignore flags mean the new user-supplied ignores compose correctly with the existing auto-derived ones. The regression test covers all three flags end-to-end.

No files require special attention.

Important Files Changed

Filename Overview
src/cli/watch.rs Adds three missing forwarding branches (--ignore, --ignore-file, --print-events) to Watch::run(), following the existing arg-forwarding style exactly; logic is sound and placement before the auto-derived ignore block is correct since watchexec unions repeated --ignore flags.
e2e/cli/test_watch_ignore New regression test that spawns mise watch in the background, polls for the exact $ watchexec debug prefix using grep -Fq to avoid false early-exit matches, kills the process, and asserts all three forwarded flags appear in the captured output.

Reviews (2): Last reviewed commit: "fix(watch): forward --ignore, --ignore-f..." | Re-trigger Greptile

Comment thread e2e/cli/test_watch_ignore Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/cli/test_watch_ignore`:
- Around line 19-23: The watch-ignore test is waiting on any occurrence of
“watchexec,” which can be satisfied by unrelated output and make the test flaky.
Update the polling in the test to wait for the specific constructed debug
command line emitted by the watchexec launch path, using the exact debug
prefix/message from the watch startup flow so the loop only exits once the
actual command is logged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: ee03e2c6-457e-4315-a953-0d7da6ba6f4c

📥 Commits

Reviewing files that changed from the base of the PR and between 61f4898 and 1564137.

📒 Files selected for processing (2)
  • e2e/cli/test_watch_ignore
  • src/cli/watch.rs

Comment thread e2e/cli/test_watch_ignore Resolved
…tchexec

`mise watch` parses watchexec flags into its own `WatchexecArgs` struct and then
rebuilds a fresh `watchexec ... -- mise run <task>` command line in
`Watch::run()`. Each flag must be explicitly re-emitted there, but `--ignore`
(`ignore_patterns`), `--ignore-file` (`ignore_files`), and `--print-events`
(`print_events`) were parsed and silently dropped, so `mise watch --ignore
'spec/**/*.rb'` had no effect.

Add the three missing forwarding branches, mirroring the existing flag-forwarding
style (and the jdx#10392 `--wrap-process` fix). The user's `--ignore` patterns are
emitted as a separate, additional `--ignore` occurrence; watchexec unions
repeated `--ignore` flags, so they combine with the source-derived ignores
rather than clobbering them.

Adds an e2e regression test that asserts the three flags appear on the
constructed watchexec command line.

Resolves the issue reported in discussion jdx#7776.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JamBalaya56562
JamBalaya56562 force-pushed the fix-watch-ignore-flags branch from 1564137 to e974731 Compare June 26, 2026 06:27
@jdx
jdx merged commit 7f23bea into jdx:main Jun 26, 2026
33 checks passed
@JamBalaya56562
JamBalaya56562 deleted the fix-watch-ignore-flags branch July 3, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants