T-020: Enhance scan — depth, ignore, and patterns#123
Closed
Conversation
…py and utils/github_api; switch dry_run decorator to log at INFO
- Updated _setup_logger() in decorators.py to use proper handler setup and propagation - Fixed _setup_error_handling_logger() in error_handling.py with explicit logger configuration - Updated all test files to use caplog.set_level() with specific logger names - Resolved issue where log messages weren't captured by pytest's caplog fixture - All 58 logging-related tests now pass successfully Tests affected: - tests/test_decorators.py: 24 tests passed - tests/utils/test_error_handling.py: 34 tests passed
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ut output - Tests expect dry-run messages in capsys.out (stdout) not in log capture - Changed dry_run_aware decorator to use print() instead of _pkg_logger.info() - All TestDryRunAware tests now pass successfully: - test_dry_run_mode_skips_execution ✅ - test_positional_dry_run_argument ✅ Fixes CI test failures that were expecting 'Would test operation' in stdout.
Implements T-020: Enhance scan — depth, ignore, and patterns (#110) ## New Features - **Hierarchical scanning**: --depth N controls scan depth (0=root only, unlimited by default) - **Pattern filtering**: --ignore PATTERN excludes files/directories (repeatable) - **Gitignore integration**: --respect-gitignore honors .gitignore rules including negation patterns - **File sampling**: JSON output includes files_sample array (default 5, configurable with --show N) ## API Changes - Enhanced collect_evidence() with depth, ignore_patterns, respect_gitignore, show_files_sample parameters - files_sample field now always present in JSON output with stable ordering - Improved gitignore parsing with support for negation patterns (!pattern) ## Testing - Added comprehensive test suites for enhanced functionality - Created golden test files for different scan scenarios - All existing tests pass, maintaining backward compatibility - 62 scan-related tests covering all new features ## Documentation - Updated README.md with new options and usage examples - Enhanced CLI help text for all new flags - Added examples for depth control, filtering, and gitignore integration Fixes #110
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
This PR implements the enhanced scan functionality as described in issue #110, adding hierarchical scanning capabilities with depth control, pattern-based filtering, and gitignore integration.
🚀 New Features
Hierarchical Scanning
--depth N: Controls scan depth (0=root only, unlimited by default)pathlib.Path.rglobfor efficient file discoveryPattern-Based Filtering
--ignore PATTERN: Excludes files/directories matching glob patterns (repeatable)--ignoreflagsGitignore Integration
--respect-gitignore: Honors .gitignore rules when scanning!pattern)File Sampling
files_sample: Always present in JSON output with stable ordering--show N: Configurable number of sample files per language (default: 5)🔧 API Changes
Enhanced
collect_evidence()FunctionJSON Schema Updates
files_sample: Array of sample file paths (always present)🧪 Testing
Comprehensive Test Coverage
test_scan_enhanced_golden.py(5 tests for golden file validation)test_scan_gitignore.py(6 tests for gitignore functionality)Test Scenarios Covered
📚 Documentation
Updated Documentation
Usage Examples
✅ Acceptance Criteria
All acceptance criteria from issue #110 are met:
🔄 Manual Test Results
All manual tests from the issue pass:
depth=0→ python onlydepth=2→ python,nodeignore pattern excludes subdir→ python onlyfiles_sample length reflects --show→ correct length.gitignore scenario→ python only (respects gitignore)files_sample always present in JSON→ true🚦 Breaking Changes
None - This is a fully backward-compatible enhancement:
files_samplefield but preserves all existing fields🔗 Related
Closes #110
Ready for review - All tests passing, documentation updated, and acceptance criteria met.