Skip to content

fix(mcp): report real changed line counts for renamed files - #1379

Merged
JSONbored merged 6 commits into
JSONbored:mainfrom
Dexterity104:fix/mcp-rename-line-counts
Jun 26, 2026
Merged

fix(mcp): report real changed line counts for renamed files#1379
JSONbored merged 6 commits into
JSONbored:mainfrom
Dexterity104:fix/mcp-rename-line-counts

Conversation

@Dexterity104

Copy link
Copy Markdown
Contributor

Summary

collectLocalBranchMetadata in the MCP package undercounted changed lines whenever a file was renamed across directories. Git renders that kind of rename in git diff --numstat as a bare old => new line with no braces, and the previous parser only understood the braced dir/{old => new}/file form. The renamed file therefore failed the numstat lookup and fell back to 0 additions and 0 deletions, which then skewed changedLineCount and 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 --numstat and git diff --name-status with -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

  • The PR title follows type(scope): short summary Conventional Commit format.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • Linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage (full npm run test:ci run is clean)
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New and changed behavior has unit tests for the rename, binary, git-failure, and non-ASCII branches.

If any required check was skipped, explain why:

  • None skipped.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized and low-noise; this change adds no public-facing text.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. (Not applicable: no such surface is touched.)
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states. (Not applicable: no UI changes.)
  • Visible UI changes include a UI Evidence section. (Not applicable: no visible UI changes.)
  • Public docs/changelogs are updated where needed; the changelog is not edited in this PR.

UI Evidence

Not applicable. This change has no visible UI, frontend, docs, or extension surface.

Notes

  • The edited file lives in packages/gittensory-mcp/lib, which sits outside Codecov's src/** scope, so codecov/patch has no changed src lines to measure. The changed code was still measured directly with the v8 reporter, and the added tests cover every reachable line and branch.
  • Verified against real git repositories on git 2.51.0 for renames within and across directories, binary modifications and binary renames, a mode change, and accented or control-character filenames at the default core.quotePath setting.

@Dexterity104
Dexterity104 requested a review from JSONbored as a code owner June 25, 2026 16:06
@dosubot dosubot Bot added the size:M label Jun 25, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.43%. Comparing base (c4a5bb8) to head (2e6b5f3).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

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:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dosubot dosubot Bot added the size:M label Jun 25, 2026
@loopover-orb

loopover-orb Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Important

Gittensory found maintainer review notes

Public GitHub metadata was checked for review readiness. Gittensor-specific context appears only when confirmed.

Readiness score: 66/100

Signal Result Evidence Action
Linked issue ⚠️ Missing No linked issue or no-issue rationale found. Explain no-issue PR.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found. No action.
Review load ✅ 20/20 Readiness component derived from cached public PR metadata and labels. No action.
Validation evidence ❌ 5/25 Cached preflight status is hold. Fix blocker.
Open PR queue ❌ 3/10 39 open PR(s), 12 likely reviewable, 27 unlinked. Expect slower review.
Contributor context ✅ Confirmed Gittensor contributor Dexterity104; Gittensor profile; 84 PR(s), 11 issue(s). No action.
Gate result ⚠️ Advisory only Advisory only. No action.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Review load = cached public PR metadata such as size labels, changed paths, and preflight status.
  • Open PR queue = repo-wide review pressure; it is not a PR quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Review context
  • Author: Dexterity104
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 84 PR(s), 11 issue(s).
  • PR-specific overlap: none found.
Maintainer notes
  • Repo lane is not ready for a confident recommendation: Repository registration is not available in the local Gittensory cache.
  • No linked issue detected: The planned PR does not reference a closing issue or explicit linked issue number.
Contributor next steps
  • Explain no-issue PR.
  • Fix blocker.
  • Expect slower review.
  • Refresh registry data or choose a registered active repo.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
  • Re-run Gittensory review

💰 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.

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jun 25, 2026

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Verdict: MERGE · gittensor:bug. -z NUL parsing fixes the 0/0 fallback for no-shared-affix renames + non-ASCII; real git fixtures, green.

@dosubot dosubot Bot added the lgtm label Jun 26, 2026
@JSONbored
JSONbored merged commit f4ea1a2 into JSONbored:main Jun 26, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants