Skip to content

feat: exclude lock files and generated files from diff animation - #25

Merged
unhappychoice merged 2 commits into
mainfrom
feat/exclude-lock-files-from-diff-24
Nov 9, 2025
Merged

unhappychoice merged 2 commits into
mainfrom
feat/exclude-lock-files-from-diff-24

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Nov 9, 2025 •

Copy link
Copy Markdown
Owner

close: #24

Summary

  • Exclude lock files and generated files from diff animation to improve performance
  • Show clear skip messages for excluded files instead of animating large auto-generated content
  • Support 23 lock file types across all supported languages
  • Support minified files and source maps

Changes

  • Add should_exclude_file() function to detect lock files and generated files
  • Add is_excluded field to FileChange struct
  • Skip excluded files in animation loop with message: 📦 {filename} (skipped - generated file)
  • Add comprehensive unit tests (5 test cases)

Supported Exclusions

Lock Files (23 types)

  • JavaScript/Node.js: yarn.lock, package-lock.json, pnpm-lock.yaml
  • Rust: Cargo.lock
  • Ruby: Gemfile.lock
  • Python: poetry.lock, Pipfile.lock
  • PHP: composer.lock
  • Go: go.sum, go.mod
  • Swift: Package.resolved
  • Dart/Flutter: pubspec.lock
  • .NET/C#: packages.lock.json, project.assets.json
  • Elixir: mix.lock
  • Java/Gradle: gradle.lockfile, buildscript-gradle.lockfile
  • Scala: build.sbt.lock

Generated Files

  • Minified files: *.min.js, *.min.css
  • Bundled files: *.bundle.js, *.bundle.css
  • Source maps: *.js.map, *.css.map, *.d.ts.map

Test Plan

  • ✅ All tests pass (5 new unit tests)
  • ✅ cargo check passes
  • ✅ cargo clippy --all-targets --all-features -- -D warnings passes
  • ✅ cargo fmt applied

Related

  • Improves performance for commits with large lock file changes
  • Similar to existing binary file handling

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Lock files, minified/bundled files, and source-map files are now automatically skipped during animation playback — the UI inserts brief pauses and shows a skip notification instead of opening or editing those files.
  • Tests

    • Added unit tests to validate exclusion detection across lock, minified, bundled, and source-map file cases.

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]>
@coderabbitai

coderabbitai Bot commented Nov 9, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds 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

Cohort / File(s) Summary
Exclusion detection
src/git.rs
Added EXCLUDED_FILES and EXCLUDED_PATTERNS constants and pub fn should_exclude_file(path: &str) -> bool. FileChange now exposes pub is_excluded: bool. Git change extraction sets is_excluded. Unit tests added for exclusion behavior.
Exclusion handling
src/animation.rs
Modified commit processing to check change.is_excluded; when true, the engine inserts a pause, prints a skipped-file message, inserts another pause, and continues without performing open/switch/edit steps.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focus areas:
    • Correctness of filename/path extraction and pattern matching in should_exclude_file.
    • Impact of adding is_excluded to FileChange on serialization/deserialization or downstream consumers.
    • Behavior and tests in src/animation.rs for state consistency when skipping files.

Possibly related PRs

Poem

🐰 I hop through diffs with a lighter heart,
Skipping lockfiles so the show can start.
A pause, a note, then onward I prance —
Generated lines won't steal our dance. 🎩✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'feat: exclude lock files and generated files from diff animation' directly and accurately describes the main change: excluding lock and generated files from diff animation.
Linked Issues check ✅ Passed The pull request addresses all primary coding requirements from issue #24: excluding lock files and generated files, implementing should_exclude_file() function, adding is_excluded field to FileChange struct, displaying skip messages during animation, and adding unit tests.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective of excluding lock and generated files from diff animation. No out-of-scope modifications were introduced.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/exclude-lock-files-from-diff-24

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e12cfe and c8a1143.

📒 Files selected for processing (1)
  • src/git.rs (4 hunks)
🔇 Additional comments (4)
src/git.rs (4)

44-56: LGTM!

The excluded patterns appropriately cover minified files, bundled files, and source maps that are typically auto-generated and provide little review value.


156-156: LGTM!

The is_excluded field appropriately extends the FileChange struct to carry exclusion state for each file change.


398-405: LGTM!

The integration correctly calls should_exclude_file and populates the is_excluded field during change extraction.


417-490: Remove incorrect test assertion for go.mod exclusion.

The test at line 438 asserts that go.mod should be excluded, but go.mod is not present in the EXCLUDED_FILES constant—only go.sum is included. This test will fail during execution. Remove the assertion:

         // Go
         assert!(should_exclude_file("go.sum"));
-        assert!(should_exclude_file("go.mod"));
         // Swift

Likely an incorrect or invalid review comment.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17028b4 and 4e12cfe.

📒 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_excluded flag from FileChange
  • 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 continue

This integrates well with the exclusion detection in src/git.rs and 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_excluded field 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_excluded at 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.

Comment thread src/git.rs Resolved
Comment thread src/git.rs
Comment on lines +59 to +76
/// 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
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude lock files and generated files from diff animation

1 participant