refactor: unify path handling with SearchPath struct#125
Closed
alexec wants to merge 9 commits into
Closed
Conversation
- Replace separate functions (AllTaskSearchPaths, AllRulePaths, etc.) with unified SearchPath struct - Add SearchPath struct with BasePath, RulesSubPaths, and TaskSubPaths fields - Replace WithRemotePaths with WithSearchPaths and WithPath options - Treat local and remote paths uniformly via go-getter - Update all tests to use new SearchPath API - Update documentation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the path handling system to use a unified SearchPath struct, replacing separate functions for managing local and remote paths. The refactoring introduces a cleaner, more flexible API where path searching is explicitly configured through options rather than being automatically included.
Key changes:
- Introduced
SearchPathstruct to unify path representation withBasePath,RulesSubPaths, andTaskSubPaths - Replaced path helper functions with
DefaultSearchPaths(baseDir, homeDir)andPathSearchPaths(dir) - Changed CLI flag from
-dto-Pand replacedWithRemotePaths()withWithSearchPaths()andWithPath()options - Unified local and remote path handling through go-getter for consistent behavior
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/codingcontext/paths.go | Introduces SearchPath struct and replaces individual path functions with unified DefaultSearchPaths() and PathSearchPaths() functions |
| pkg/codingcontext/context.go | Updates Context struct with searchPaths and paths fields; adds WithSearchPaths() and WithPath() options; updates findTaskFile() and findExecuteRuleFiles() to use new search path structure |
| pkg/codingcontext/remote.go | Renames downloadRemoteDirectory() to downloadPath() to reflect unified handling of both local and remote paths |
| pkg/codingcontext/context_test.go | Adds getTestSearchPaths() helper and updates all tests to use new API with explicit searchPaths configuration |
| pkg/codingcontext/README.md | Documents new SearchPath struct, DefaultSearchPaths(), PathSearchPaths(), WithSearchPaths(), and WithPath() functions |
| main.go | Changes CLI flag from -d to -P, retrieves homeDir for default search paths, and constructs options using new WithSearchPaths() and WithPath() API |
| integration_test.go | Updates integration test to use new -P flag instead of -d |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…Dirs from Context
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.
Summary
Refactors path handling to use a unified
SearchPathstruct instead of separate functions for local and remote paths.Changes
SearchPathstruct withBasePath,RulesSubPaths,TaskSubPaths, andDownloadedDirfieldsAllTaskSearchPaths,AllRulePaths,DownloadedRulePaths, andDownloadedTaskSearchPathsfunctions with:DefaultSearchPaths(baseDir, homeDir)- returns search paths for default local pathsPathSearchPaths(dir)- returns search paths for a given directory (used for both local and remote)NewSearchPathWithDefaults(basePath)- creates a SearchPath with default subpathsWithRemotePathsoption with:WithSearchPaths([]SearchPath)- sets search paths directlyNewSearchPathWithDefaultsinstead of empty subpathsDownloadedDirfield toSearchPathto track downloaded directories directly on the structdownloadedDirs []stringfield fromContextstruct (replaced byDownloadedDironSearchPath)TaskSearchDirs()andRulesSearchDirs()to useDownloadedDirif set, otherwiseBasePathhomeDirparameter fromfindTaskFileandfindExecuteRuleFilesfunctionsisRemoteURLguard - all paths go through go-getter which handles both local and remoteBenefits
WithSearchPaths(DefaultSearchPaths(...))