Skip to content

Commit 21f7ffd

Browse files
committed
Update DEVELOPMENT_PLAN with improved gitignore handling design
- Add critical fixes section for system directory exclusion logic - Document issues with current gitignore handling - Design a GitIgnoreContext approach for recursive .gitignore handling - Add test strategy for nested repositories - Update roadmap to reflect gitignore enhancement priorities
1 parent 5cdbead commit 21f7ffd

File tree

1 file changed

+97
-12
lines changed

1 file changed

+97
-12
lines changed

DEVELOPMENT_PLAN.md

Lines changed: 97 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,41 @@ Smart Tree is a modern directory tree viewer that intelligently displays file hi
1414
- **GitIgnore Integration**: Basic folding based on gitignore patterns
1515
- **Metadata Display**: File sizes, modification times, directory statistics
1616
- **CLI Interface**: Configurable options via command line arguments
17+
- **Color and Emoji Support**: Rich visual enhancements for improved readability
1718

1819
### Known Issues
1920

20-
- Gitignore pattern matching could be further improved
21-
- Performance concerns for large directory structures
22-
- Full directory tree kept in memory (could be problematic for large trees)
23-
- Limited terminal width consideration
21+
-~~Gitignore pattern matching could be further improved~~
22+
-~~Performance concerns for large directory structures~~
23+
-~~Full directory tree kept in memory (could be problematic for large trees)~~
24+
-~~Limited terminal width consideration~~
25+
-~~T-shape vs L-shape connectors display incorrectly for the last items~~
26+
-~~Program collapses lines where only 1 item is hidden (inefficient)~~
27+
- Contents of .git (and other system directories) cannot be viewed even when explicitly requested
28+
- Does not properly respect nested .gitignore files in subdirectories
29+
- No option to explicitly show system directories that are normally hidden
2430

2531
## Development Roadmap
2632

27-
### Phase 1: Code Cleanup and Bug Fixes (Immediate Priority) ✅
33+
### Critical Fixes (Immediate Priority)
34+
35+
1. **Fix System Directory Exclusion Logic**
36+
- Add a flag to explicitly show contents of system directories
37+
- Modify `display/state.rs` to respect this flag when rendering directories
38+
- Update state logic to process gitignored directories when explicitly requested
39+
40+
2. **Improve .gitignore Detection and Handling**
41+
- Implement recursive .gitignore detection to respect nested .gitignore files
42+
- Load and apply .gitignore rules at each directory level
43+
- Cache gitignore patterns to avoid redundant file reads
44+
- Add option to toggle .gitignore consideration
45+
46+
3. **Explicit Directory Inclusion Options**
47+
- Add command-line parameter to explicitly include directories that would otherwise be folded
48+
- Support glob patterns for directory inclusion/exclusion
49+
- Fix logic handling of included directories to properly scan and display their contents
50+
51+
### Phase 1: Code Cleanup and Bug Fixes (Completed) ✅
2852

2953
1. **Fix Test Suite Errors**
3054
- Remove duplicated test_utils module and ExpectedContent struct
@@ -36,26 +60,28 @@ Smart Tree is a modern directory tree viewer that intelligently displays file hi
3660
- Apply consistent formatting with `cargo fmt`
3761
- Run clippy and fix linting issues
3862

39-
3. **Improve Error Handling**
63+
3. **Improve Error Handling**
4064
- Review use of unwrap/expect and replace with proper error handling
4165
- Improve error messages and recovery
4266

43-
### Phase 2: Core Functionality Enhancement (Short Term)
67+
### Phase 2: Core Functionality Enhancement (Current)
4468

45-
1. **Improve GitIgnore Integration**
46-
- Implement proper gitignore pattern matching
47-
- Support standard gitignore syntax with globs
69+
1. **Improved GitIgnore Integration** 🚧
70+
- ✅ Implement proper gitignore pattern matching
71+
- ✅ Support standard gitignore syntax with globs
72+
- Add proper recursive .gitignore file detection and pattern application
73+
- Add option to toggle .gitignore consideration
4874

4975
2. **Memory Optimization**
5076
- Implement streaming/lazy loading approach for large directories
5177
- Reduce memory usage for very large directory structures
5278

53-
3. **Performance Improvements**
79+
3. **Performance Improvements** 🚧
5480
- Optimize directory traversal for large directory structures
5581
- Implement metadata caching for frequently accessed directories
5682
- Consider parallel scanning for improved performance
5783

58-
### Phase 3: UI and UX Enhancements (Medium Term)
84+
### Phase 3: UI and UX Enhancements (In Progress)
5985

6086
1. **Terminal Integration**
6187
- Add terminal width consideration for improved display
@@ -118,6 +144,65 @@ Smart Tree is a modern directory tree viewer that intelligently displays file hi
118144
- Implement extensions for popular development tools
119145
- Add language-specific statistics gathering
120146

147+
## Implementation Details for Upcoming Work
148+
149+
### Gitignore and System Directory Handling Design
150+
151+
1. **Recursive GitIgnore Detection**
152+
```
153+
App
154+
├── .gitignore (ignores *.log)
155+
├── src/
156+
│ ├── .gitignore (ignores *.tmp)
157+
│ └── components/
158+
│ ├── .gitignore (ignores *.bak)
159+
│ └── ...
160+
└── ...
161+
```
162+
163+
- Each directory's .gitignore rules should apply to itself and all subdirectories
164+
- Later .gitignore files take precedence over earlier ones
165+
- Parent rules can be negated by child rules (using ! prefix)
166+
167+
2. **Scanner Implementation**
168+
```rust
169+
pub struct GitIgnoreContext {
170+
patterns: Vec<GitIgnore>,
171+
}
172+
173+
impl GitIgnoreContext {
174+
// Load initial .gitignore from root
175+
pub fn new(root: &Path) -> Self { ... }
176+
177+
// Check if path matches any pattern in any loaded .gitignore
178+
pub fn is_ignored(&self, path: &Path) -> bool { ... }
179+
180+
// Process a directory, loading any .gitignore found there
181+
pub fn process_directory(&mut self, dir_path: &Path) { ... }
182+
}
183+
```
184+
185+
3. **System Directory Handling**
186+
- Add new CLI option: `--show-system-dirs` to show system directories
187+
- Modify scanner to mark system dirs but traverse them if explicitly requested
188+
- Update display logic to respect this setting
189+
190+
## Test Strategy
191+
192+
1. **Unit Tests for GitIgnore Context**
193+
- Test recursive .gitignore file loading
194+
- Test pattern application from multiple .gitignore files
195+
- Test precedence rules between parent and child patterns
196+
197+
2. **Integration Tests with Nested Repositories**
198+
- Set up test directories with nested git repositories
199+
- Verify correct traversal behavior with and without explicit inclusion
200+
- Test with `--show-system-dirs` flag
201+
202+
3. **End-to-End Testing**
203+
- Create a test suite that verifies real-world nested repository scenarios
204+
- Test performance with large repositories containing multiple .gitignore files
205+
121206
## Implementation Notes
122207

123208
- Maintain modular architecture with clear separation of concerns

0 commit comments

Comments
 (0)