[minor] Replace LibGit2Sharp with the git command line - #377
Conversation
|
Keeping this open — do not close as part of the SDK-sweep cleanup. Audited during the org-wide cleanup of the It contains genuinely unmerged feature work:
StateThe branch is 3 ahead / 36 behind Suggested pathRebase onto |
libgit2 implements neither the clean and smudge filters nor the hooks, and Git LFS is built entirely out of those. For this application the half that bites is the smudge filter: cloning through LibGit2Sharp writes each LFS pointer to disk as its literal text, so a repository that tracks binaries comes down looking like a set of three-line files rather than its content. All git work now goes through GitCli, which starts the git command through ktsu.RunCommand. Arguments are passed as a list rather than as one command string, so paths containing spaces need no quoting, and RunIn uses git -C so the process working directory is never mutated -- which is what keeps the background fetches safe to run concurrently. Notable call site changes: - Clone, fetch and status move across directly. Pull becomes --ff-only. The old code performed a real merge, committed it unattended, and swallowed CheckoutConflictException, which left the working tree mid-conflict with nothing said about it. - Repository discovery takes the parent of each .git directory rather than asking libgit2 for the working directory, and reads the remote with git remote get-url. - The index enumeration behind the repository diff becomes git ls-files -z. NUL separation turns off the quoting git otherwise applies to unusual paths, so names arrive exactly as recorded. - RepositoryNotFoundException was driving control flow in four places. Those become an explicit GitCli.IsRepository check. - The log panel carried libgit2's debug trace. It now carries what git reported for each clone, fetch and pull, which is what someone watching that panel actually wants to see. There are no credentials in this code any more: git uses the platform credential helper, which also makes SSH remotes work. Add ProjectDirector.Test, the repository's first test project. GitCliTests pins both halves of the LFS guarantee -- a tracked binary is committed as a pointer and comes back out of a clone as its content -- plus the repository detection, tracked-file listing and remote lookup that replaced the exception handling. Also correct the solution configuration, which mapped Release to Debug, so building Release produced a Debug binary. Rebased onto main (2026-08-20), dropping the obsolete "[patch] Sync to ktsu.Sdk 2.21.1" commit this branch was originally stacked on -- main is on 2.27.2 and already carries the header, .gitattributes and .editorconfig migrations that commit was making. Resolved against current main: - Directory.Packages.props / ProjectDirector.csproj kept main's package versions, added ktsu.RunCommand and dropped LibGit2Sharp. - Removed the Microsoft.Testing.Extensions.CodeCoverage and .TrxReport pins. MSTest.Sdk injects both itself, so they became duplicate PackageVersion items (NU1506) the moment this branch added the repository's first test project. - README.md, DESCRIPTION.md and TAGS.md still described the application as using LibGit2Sharp; updated to match.
b4a275a to
ffbe2c6
Compare
|
|
Conflicts resolved — rebased onto Rather than rebasing all three commits, I dropped the obsolete Resolutions
Two things that needed fixing beyond the conflicts
VerificationClean rebuild from a scratch worktree: 0 errors, 0 warnings, and 7/7 tests pass. CI agrees — One check still red: SonarCloud
This is structural rather than something the rebase introduced — the repo had no test project at all until this PR, so there is no coverage baseline to inherit. Of 64 new lines to cover, 37 are uncovered:
Clearing the gate needs 25 of those 37 lines covered, so |


No description provided.