Skip to content

watch: ignore files by pattern via .gocutignore and --ignore - #4

Merged
emoss08 merged 1 commit into
mainfrom
claude/quirky-cerf-l5b9gy
Nov 7, 2026
Merged

emoss08 merged 1 commit into
mainfrom
claude/quirky-cerf-l5b9gy

Conversation

@emoss08

@emoss08 emoss08 commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Summary

gocut watch can now ignore files by pattern. It reads gitignore-style patterns from .gocutignore in --root, plus any --ignore <pattern> flags, which are applied after the file. A file that matches never starts a build or a restart. A directory that matches is not watched, which also saves inotify watches.

*_mock.go          # file name at any depth
mocks/             # directory only
internal/gen/*.go  # contains a /, so it's anchored to --root
**/fixtures/**
*_gen.go
!wire_gen.go       # negation; the last match wins

Notes:

  • _test.go files and testdata/ already never started a build. That hasn't changed.
  • Supported syntax: *, ?, [abc] / [a-z] / [!abc], **, !, # comments, and \ escapes. As with gitignore, a file under an ignored directory can't be re-included.
  • Patterns apply only under --root, so packages reached through a replace outside it aren't affected.
  • The -toolexec compile path is unchanged.
  • No new dependencies: the glob matcher is a small one in src/ignore.rs, with unit tests.

Testing

  • cargo fmt --check, cargo clippy --all-targets --locked -- -D warnings and cargo test --locked (35 tests) all pass.
  • New unit tests cover glob matching, line parsing, anchoring, directory-only patterns, negation, skip_dir, and Watcher::consider with ignored files.
  • Manual end-to-end run: edits to ignored files (from both .gocutignore and --ignore) started nothing, an edit to a non-ignored file rebuilt, and the ignored directory was not watched.

Generated by Claude Code

gocut watch reads gitignore-style patterns from .gocutignore in --root,
plus any --ignore flags (applied after the file). A matching file never
starts a build or a restart, and a matching directory is not watched.

Supports name patterns at any depth, root-anchored paths, trailing-slash
directory-only patterns, *, ?, [...] classes, ** and ! negation (last
match wins; a file under an ignored directory stays ignored). Patterns
apply only under --root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AcYXsJeqDL2ULiRzRmtw94
@emoss08
emoss08 marked this pull request as ready for review November 7, 2026 08:20
@emoss08
emoss08 merged commit c769a9a into main Nov 7, 2026
6 checks passed
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