Repository navigation
fix(collector): record real file paths and Git's own change status - #22
Merged
Merged
Conversation
git log --numstat abbreviates renames as dir/{old => new}/file, and the
collector split that on ' => ', recording corrupted paths for 110 of this
repository's 134 renames. Status was also guessed from line counts, so an
append-only edit was reported as an added file.
Add --raw to the same git log call and pair its entries (status letter
plus full old/new paths) with numstat line counts, which Git emits in the
same order. On a count mismatch, fall back to numstat with brace
expansion and record a warning. Pass core.quotePath=false and decode the
stream as UTF-8 so non-ASCII filenames keep their real names.
Refs ps-001.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Every file change in a report now names the real file and the status Git reports.
git log --numstatabbreviates renames that share part of a path asdir/{old => new}/file. The collector split that on=>, recording paths likenew}/fileand old paths likedir/{old. In this repository 110 of 134 renames were affected, skewing hotspots, file counts, file types, and file ownership.addedand a removal-only edit asdeleted.Approach
--rawto the same singlegit logcall. Git emits raw entries (status letter plus full old/new paths) in the same order as numstat entries, so the two are paired by position: status and paths from raw, line counts from numstat.-c core.quotePath=false, decode Git's C-quoted paths, and decode stdout as a UTF-8 stream so non-ASCII filenames keep their real names even when a character spans two chunks.src/core/git-paths.ts, so they are not added to the public API viaexport *.FileChangekeeps its shape; only its values become correct. Spawn arguments remain a fixed array.Out of scope:
--followand merging a renamed file's history with its old path.Verification
test/file-change-records.test.tsagainst a real Git repo: added non-ASCII filename, append-only edit (modified), brace-form rename (fullpath/oldPath), delete, no braces or arrows in any path, plus unit tests for rename expansion and path unquoting. 4 of its tests fail on the previous collector.{,}or=>; all 134 renames carry full paths; 0 fallback warnings.Release note
Status counts in reports shift (appends are now
modified). JSON values change, not the schema; choose patch or minor at release. CHANGELOG[Unreleased]has the entries.Roadmap: ps-001 (accurate per-file change records).
🤖 Generated with Claude Code