local: handle ghq-style repo layouts#11
Conversation
There was a problem hiding this comment.
Pull request overview
This PR increases the default scan depth for local repository discovery from 2 to 4 to support ghq-style repository layouts (e.g., ~/ghq/github.com/owner/repo). This change enables the application to discover repositories nested 3-4 directory levels below the configured root path.
Key Changes
- Increased
defaultMaxDepthconstant from 2 to 4 inLocalProjectsConstants - Added inline documentation explaining the rationale for the increased depth to support ghq-style layouts
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Allow ghq-style layouts (e.g. ~/ghq/github.com/owner/repo) which sit 3–4 levels | ||
| // below the configured root path. |
There was a problem hiding this comment.
The comment states ghq-style repos "sit 3–4 levels below the configured root path", but the depth calculation may be confusing. For a path like ~/ghq/github.com/owner/repo where the root is ~/ghq, the repo directory is at depth 3 (github.com=1, owner=2, repo=3). With maxDepth=4, the scanner checks depths 0-3 (since the condition is depth < maxDepth). Consider clarifying the comment to explain that maxDepth=4 allows scanning up to 3 levels deep from the root, or provide a concrete example showing the depth counting.
| // Allow ghq-style layouts (e.g. ~/ghq/github.com/owner/repo) which sit 3–4 levels | |
| // below the configured root path. | |
| // Allow ghq-style layouts, e.g. ~/ghq/github.com/owner/repo when the root is ~/ghq. | |
| // Depth is counted from the root directory (root = depth 0), so in this example: | |
| // github.com = depth 1, owner = depth 2, repo = depth 3. | |
| // With defaultMaxDepth = 4 and a depth check like `depth < maxDepth`, depths 0–3 | |
| // are scanned, which covers repos up to 3 levels below the configured root path. |
| public static let defaultMaxDepth: Int = 2 | ||
| // Allow ghq-style layouts (e.g. ~/ghq/github.com/owner/repo) which sit 3–4 levels | ||
| // below the configured root path. | ||
| public static let defaultMaxDepth: Int = 4 |
There was a problem hiding this comment.
Increasing the default scan depth from 2 to 4 doubles the number of directory levels traversed during repository discovery. This could significantly impact performance for users with deeply nested directory structures or many directories at intermediate levels. Consider adding test coverage for the deeper scanning behavior with maxDepth=4 to ensure it performs acceptably, similar to the existing tests that use maxDepth values of 1 and 2.
|
Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: dcb76d7d12b284b14dd99108b34d753a3f695dc1\n- Merge commit: 0d590c2\n\nThanks @shunkakinoki! |
Summary
Reference