Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request enhances the gf run command by adding support for custom ignore patterns during directory watching for live reload. It introduces a new -i/--ignorePatterns CLI flag, refactors the directory watching logic to use a breadth-first search algorithm for determining which directories to monitor, and adds unit tests to verify the new functionality.
Key changes:
- Adds customizable ignore patterns via the
-i/--ignorePatternsflag with corresponding struct field and CLI integration - Replaces flat directory watching with a BFS-based algorithm (
getWatchPaths) that intelligently determines the minimal set of directories to watch while respecting ignore patterns - Includes helper functions (
hasIgnoredDescendant,isIgnoredDirName) and default ignore patterns for common non-source directories like.git,node_modules, andvendor
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
cmd/gf/internal/cmd/testdata/fix/fix25_content.go |
Removes unused imports (fmt, time, gtest) from test data file |
cmd/gf/internal/cmd/cmd_z_unit_run_test.go |
Adds unit tests for getWatchPaths method covering basic functionality, empty watch paths, and custom ignore patterns |
cmd/gf/internal/cmd/cmd_run.go |
Main implementation: adds IgnorePatterns field to cRunApp struct, registers new CLI flag, implements BFS-based directory watching algorithm with helper functions, and updates command documentation/examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
houseme
approved these changes
Dec 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a significant enhancement to the
gf runcommand, focusing on improving the directory watching mechanism for hot-reload functionality. The main improvements include a more intelligent and efficient algorithm for determining which directories to watch (recursively or non-recursively), support for custom ignore patterns, and a comprehensive set of unit tests to ensure correctness. Additionally, some outdated database drivers were removed from the dependencies.Key changes:
Directory Watching Improvements
cmd_run.goto use a DFS-based algorithm that minimizes the number of watched directories while respecting ignored patterns. Directories and their descendants without ignored subdirectories are watched recursively; otherwise, non-recursive watches are set, and valid children are recursed into. This results in more efficient and accurate hot-reload behavior. (cmd/gf/internal/cmd/cmd_run.go)-i/--ignorePatternsflag, allowing users to specify directories to be excluded from watching. Default ignored patterns includenode_modules,vendor, hidden directories, and directories starting with an underscore. (cmd/gf/internal/cmd/cmd_run.go) [1] [2] [3]cmd/gf/internal/cmd/cmd_run.go)User Experience and Documentation
cmd/gf/internal/cmd/cmd_run.go) [1] [2]Testing
getWatchPathslogic, covering various scenarios including custom ignore patterns, deeply nested structures, multiple roots, non-existent directories, and edge cases. (cmd/gf/internal/cmd/cmd_z_unit_run_test.go)Dependency Cleanup
go.modto streamline the project dependencies. (cmd/gf/go.mod)These changes collectively make the hot-reload feature more robust, configurable, and efficient, while ensuring maintainability through thorough testing.