Skip to content

feat(git)!: replace dugite with tsgit, own the unified-diff rendering - #64

Merged
mcarvin8 merged 3 commits into
mainfrom
migrate-tsgit-diff-backend
Aug 10, 2026
Merged

feat(git)!: replace dugite with tsgit, own the unified-diff rendering#64
mcarvin8 merged 3 commits into
mainfrom
migrate-tsgit-diff-backend

Conversation

@mcarvin8

Copy link
Copy Markdown
Owner

Summary

  • Drops the bundled dugite git binary for @scolladon/tsgit, a pure-TypeScript git implementation with zero native dependencies — no git binary required on any platform, no more Alpine/musl workaround.
  • tsgit's diff() returns structured DiffChange data, not patch text, so smart-diff now materializes blob content via readBlob and renders its own unified diffs (Myers line-diff + hunk grouping). This also fixes a latent correctness gap: getDiff and getDiffSummary previously derived counts from two separate git diff passes (--numstat / --name-status) that could in principle disagree; they now share one blob-diff pass, so they can't.
  • Path filtering (tsgit's diff() has no pathspec support) moved client-side to a predicate over the returned DiffChange[].
  • getCommits now uses tsgit's log() with all-parent date ordering, fixing the previous first-parent-only range bug for free.

Breaking changes (major version)

  • createGitClient is now async, returning a tsgit Repository handle instead of a { run(args) } shell wrapper. Call git.dispose() when done.
  • buildDiffPathspecs, buildDiffShapingGitArgs, and parseDiffSummary are removed, replaced by buildPathFilterPredicate, direct renderer options, and buildFileSummary / mergeFileSummariesByPath / summarizeFiles.
  • Node engine requirement bumped to >=22.22.1 (tsgit's actual minimum, tighter than the previous >=22).

Full details in the README's "Migrating from 3.x → 4.x" section.

Test plan

  • npm run lint (biome) clean
  • tsc --noEmit clean
  • npm test — 320 tests passing, 100% statements/branches/functions/lines coverage
  • npx knip clean (no unused deps/exports)
  • npm run build succeeds (CLI + library bundles)
  • Manually ran the built CLI against this repo's real commit history to confirm the git-gathering pipeline works end-to-end outside of tests

🤖 Generated with Claude Code

mcarvin8 and others added 3 commits August 10, 2026 16:46
Drops the bundled dugite git binary in favor of @scolladon/tsgit, a
pure-TypeScript git implementation with zero native dependencies — no
git binary required on any platform, no more Alpine/musl workaround.

tsgit's diff() returns structured DiffChange data, not patch text, so
smart-diff now materializes blob content via readBlob and renders its
own unified diffs (Myers line-diff + hunk grouping), which also fixes
a latent bug: getDiff and getDiffSummary previously derived counts
from two separate `git diff` passes (--numstat / --name-status) that
could in principle disagree; they now share one blob-diff pass.

Path filtering (no pathspec support in tsgit) moved client-side to a
predicate over the returned DiffChange[]. getCommits now uses tsgit's
log() with all-parent ordering, fixing the previous first-parent-only
range bug for free.

BREAKING CHANGE: createGitClient is now async and returns a tsgit
Repository handle instead of a `{ run(args) }` shell wrapper.
buildDiffPathspecs, buildDiffShapingGitArgs, and parseDiffSummary are
removed in favor of buildPathFilterPredicate, direct renderer options,
and buildFileSummary/mergeFileSummariesByPath/summarizeFiles. Node
engine requirement bumped to >=22.22.1 (tsgit's actual minimum).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
getRepoRoot() returns the canonical path, but macOS symlinks /var to
/private/var — the raw mkdtemp path never matched on that platform.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
realpathSync (JS fallback) resolves symlinks but not NTFS 8.3 short-name
aliasing, which is what GitHub's Windows runners hit (TEMP resolves under
RUNNER~1 but tsgit's getRepoRoot() returns the long form runneradmin).
realpathSync.native calls the OS's own canonicalization and handles both.
Also re-normalize both sides at assertion time in the two comparisons, on
top of normalizing at fixture-creation time.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mcarvin8
mcarvin8 merged commit bc538a3 into main Aug 10, 2026
6 checks passed
@mcarvin8
mcarvin8 deleted the migrate-tsgit-diff-backend branch August 10, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant