Repository navigation
feat: exclude lock files and generated files from diff animation - #25
Conversation
Add exclusion logic for lock files and generated files to improve performance and user experience. Large auto-generated files like package-lock.json or Cargo.lock are now skipped during diff animation with a clear skip message. - Add should_exclude_file() function to detect lock files and generated files - Support 23 lock file types across all supported languages (JS, Rust, Go, Swift, etc.) - Support minified files (.min.js, .min.css) and source maps (.js.map, etc.) - Add is_excluded field to FileChange struct - Skip excluded files in animation loop with skip message - Add comprehensive unit tests for exclusion logic 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
WalkthroughAdds exclusion detection for lock/generated files in the git layer and short-circuits animation for those changes by inserting a brief pause and skip message instead of opening/switching/editing the file. Changes
Sequence Diagram(s)sequenceDiagram
participant G as Git Extractor
participant C as Commit Loader
participant A as Animator
G->>C: emit FileChange(path, is_excluded)
loop for each FileChange
C->>A: process(change)
alt change.is_excluded == true
rect rgb(245,245,245)
A->>A: pause
A->>A: print "skipped-file" message
A->>A: pause
end
else
rect rgb(200,220,255)
A->>A: open file
A->>A: switch buffer
A->>A: animate edits
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/animation.rs(1 hunks)src/git.rs(4 hunks)
🔇 Additional comments (5)
src/animation.rs (1)
287-300: LGTM! Clean integration of exclusion handling.The exclusion logic correctly:
- Checks the
is_excludedflag fromFileChange- Shows an appropriate skip message with the file path
- Uses sensible pause durations to maintain flow
- Skips all subsequent file processing (open, edit, git add) via
continueThis integrates well with the exclusion detection in
src/git.rsand matches the PR objectives.src/git.rs (4)
45-57: LGTM! Comprehensive patterns for generated files.The pattern list appropriately covers:
- Minified assets (
.min.js,.min.css)- Bundled outputs (
.bundle.js,.bundle.css)- Source maps (
.js.map,.css.map,.d.ts.map)All patterns start with
.which ensures correct matching without false positives.
157-157: LGTM! Field addition is well-placed.The
is_excludedfield is appropriately:
- Positioned with other boolean flags (
is_binary)- Declared as public for consumption by
animation.rs- Named clearly and consistently with the codebase style
399-406: LGTM! Efficient exclusion detection placement.Computing
is_excludedat this point is optimal because:
- The file path is already determined
- It occurs before potentially expensive content loading operations
- Excluded files can skip unnecessary processing early
The integration is clean and maintains the existing code structure.
418-491: LGTM! Comprehensive test coverage.The test suite thoroughly validates:
- All 23 lock file types across multiple languages
- Pattern matching for minified, bundled, and source map files
- Path-qualified filenames (with directories)
- Negative cases ensuring normal files are not excluded
The tests are well-organized, clearly named, and provide strong confidence in the exclusion logic.
| /// Check if a file should be excluded from diff animation | ||
| pub fn should_exclude_file(path: &str) -> bool { | ||
| let filename = path.rsplit('/').next().unwrap_or(path); | ||
|
|
||
| // Check if it's a lock file | ||
| if EXCLUDED_FILES.contains(&filename) { | ||
| return true; | ||
| } | ||
|
|
||
| // Check if it matches excluded patterns | ||
| for pattern in EXCLUDED_PATTERNS { | ||
| if filename.ends_with(pattern) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| false | ||
| } |
There was a problem hiding this comment.
Use std::path::Path for cross-platform path handling.
The current implementation uses rsplit('/') which only handles Unix-style paths. On Windows, paths use backslashes (\), so "C:\project\Cargo.lock".rsplit('/').next() would return the entire path instead of just the filename.
Apply this diff for proper cross-platform support:
pub fn should_exclude_file(path: &str) -> bool {
- let filename = path.rsplit('/').next().unwrap_or(path);
+ let filename = Path::new(path)
+ .file_name()
+ .and_then(|name| name.to_str())
+ .unwrap_or(path);
// Check if it's a lock file
if EXCLUDED_FILES.contains(&filename) {Note: Path is already imported at line 6.
🤖 Prompt for AI Agents
In src/git.rs around lines 59 to 76, the code uses path.rsplit('/') to get the
filename which fails on Windows paths; replace that logic with
std::path::Path-based extraction (Path::new(path).file_name().and_then(|s|
s.to_str()).unwrap_or(path)) to obtain a cross-platform filename string and then
use that filename for the existing EXCLUDED_FILES and EXCLUDED_PATTERNS checks.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
close: #24
Summary
Changes
should_exclude_file()function to detect lock files and generated filesis_excludedfield toFileChangestruct📦 {filename} (skipped - generated file)Supported Exclusions
Lock Files (23 types)
yarn.lock,package-lock.json,pnpm-lock.yamlCargo.lockGemfile.lockpoetry.lock,Pipfile.lockcomposer.lockgo.sum,go.modPackage.resolvedpubspec.lockpackages.lock.json,project.assets.jsonmix.lockgradle.lockfile,buildscript-gradle.lockfilebuild.sbt.lockGenerated Files
*.min.js,*.min.css*.bundle.js,*.bundle.css*.js.map,*.css.map,*.d.ts.mapTest Plan
cargo checkpassescargo clippy --all-targets --all-features -- -D warningspassescargo fmtappliedRelated
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests