Parse ignore files without the scanner line limit - #31
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Preserve lone-CR-terminated patterns by stripping \r only when it follows a newline.
Pull request overview
This PR updates ignore-file parsing to support lines exceeding the scanner limit while preserving line metadata and newline handling.
Changes:
- Replaces scanner-based parsing with byte-based iteration.
- Adds regression tests and benchmarks for long lines, comments, CRLF, and loading paths.
File summaries
| File | Summary |
|---|---|
long_lines_test.go |
Adds long-line regression coverage and benchmarks. |
gitignore.go |
Implements unrestricted byte-based parsing. Moderate issue (1 vote): trailing \r is removed from final lines without \n, changing existing behavior. |
Review details
Suppressed comments (1)
gitignore.go:438
- This unconditionally removes a trailing
\r, including when the input's final line has no\n. That changes the existingbufio.ScanLinesbehavior for a lone-CR-terminated pattern (foo\rbecomesfoo), which can change both matching and reported pattern text. Only strip\rwhenbytes.Cutfound a newline, i.e. for CRLF.
raw = bytes.TrimSuffix(raw, []byte{'\r'})
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Ignore files with a line longer than the scanner limit silently lost every later rule, even when that line was a comment. Iterate over the loaded bytes so all lines are parsed, preserving CRLF handling and source line numbers.
Adds regression coverage against Git for long patterns and comments through
AddPatterns,AddFromFile, andNew.Fixes #28.