feat: add diff filtering for large staged changes#7
Merged
Conversation
Introduces a new filtering module for processing unified diffs with support for line limits per file and glob-based pattern exclusion. Includes Options and Result structs, a Filter function, and comprehensive unit tests covering truncation, exclusion patterns, and deterministic output ordering.
Add FilterConfig struct to support configurable diff filtering with max_file_lines, default_exclude_patterns, and exclude_patterns fields. Implement merging of filter configuration from both user and repository level configs, with repo-level settings taking precedence for max_file_lines and default patterns, and exclude_patterns being accumulated across layers.
Integrate diff filtering into the commitDiff function to apply exclusion patterns and file truncation before sending the diff to the LLM. Configure filtering options from the application config and append a filter notice when files are excluded or truncated.
The previous default of 200 lines per file was too permissive and could cause diffs to exceed LLM context limits. Reducing to 100 lines provides better compatibility with token constraints while still capturing meaningful code changes for commit message generation.
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
[filter]section in config.tomlChanges
internal/git/filter.go: New filtering module with glob pattern matchinginternal/config/config.go: AddFilterConfigstructinternal/app/app.go: Integrate filtering intocommitDiff()README.md: Document new filter settingsTest plan
go test ./...)make build)