fix(mcp): report real changed line counts for renamed files - #1379
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1379 +/- ##
=======================================
Coverage 95.43% 95.43%
=======================================
Files 193 193
Lines 21044 21044
Branches 7618 7618
=======================================
Hits 20084 20084
Misses 383 383
Partials 577 577 🚀 New features to boost your workflow:
|
|
Important Gittensory found maintainer review notesPublic GitHub metadata was checked for review readiness. Gittensor-specific context appears only when confirmed. Readiness score: 66/100
Signal definitions
Review context
Maintainer notes
Contributor next steps
💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers. |
JSONbored
left a comment
There was a problem hiding this comment.
Verdict: MERGE · gittensor:bug. -z NUL parsing fixes the 0/0 fallback for no-shared-affix renames + non-ASCII; real git fixtures, green.
Summary
collectLocalBranchMetadatain the MCP package undercounted changed lines whenever a file was renamed across directories. Git renders that kind of rename ingit diff --numstatas a bareold => newline with no braces, and the previous parser only understood the braceddir/{old => new}/fileform. The renamed file therefore failed the numstat lookup and fell back to 0 additions and 0 deletions, which then skewedchangedLineCountand the local scorer preview.The same lookup also broke for filenames containing non-ASCII or control characters: the human diff format quotes those paths, so the numstat key and the name-status key stopped matching and the stats were dropped to zero there too.
The fix reads both
git diff --numstatandgit diff --name-statuswith-z. That machine format emits every path verbatim and lists a rename as separate old and new fields, so the numstat key always matches the name-status key. Renamed files, binary renames, and accented or control-character paths now report correct counts, and the brittle brace regex is gone. As a bonus, downstream consumers that read files by path now receive the real path bytes instead of quoted, escaped strings.No issue is linked: this is a small, self-contained correctness fix in the MCP local diff parser.
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coverage(fullnpm run test:cirun is clean)npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
Safety
UI Evidencesection. (Not applicable: no visible UI changes.)UI Evidence
Not applicable. This change has no visible UI, frontend, docs, or extension surface.
Notes
packages/gittensory-mcp/lib, which sits outside Codecov'ssrc/**scope, socodecov/patchhas no changedsrclines to measure. The changed code was still measured directly with the v8 reporter, and the added tests cover every reachable line and branch.core.quotePathsetting.