fix: improve error messages when git executable not found or Husky path unconfigured#165
fix: improve error messages when git executable not found or Husky path unconfigured#165
Conversation
…t configured Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
alirezanet
left a comment
There was a problem hiding this comment.
would be nice to have a integration test to simulate the problem and make sure the error message is what we expect.
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
Added two integration tests in
|
When
dotnet husky runfails becausegitisn't in PATH orhusky installwas never run (common in CI), the error output was misleading —"failed to execute command 'git'"was emitted for all failures (including non-zero exit codes), and"Could not find Husky path"gave no actionable guidance.Changes
HuskyCliWrap.cs—ExecBufferedAsyncnow distinguishes executable-not-found (Win32ExceptionNativeErrorCode 2/3) from other failures:"'git' executable not found. Make sure 'git' is installed and available in your PATH.""failed to execute command 'git'"message retainedGit.cs—GetHuskyPath()error message updated from the opaque"Could not find Husky path"to"Could not find Husky path. Make sure Husky is installed (run: dotnet husky install)"— covering the common CI case wherehusky installwas never runGitTests.cs— Added unit test verifyingGetHuskyPathAsync()throws aCommandExceptioncontaining thedotnet husky installhint on failureGitErrorMessageTests.cs— Added Docker-based integration tests that simulate the real failure scenarios:HuskyRun_WhenHuskyIsNotInstalled_ShouldShowInstallHintInErrorMessage— simulates the exact CI scenario from the issue (tools restored butdotnet husky installnever run), verifies stderr contains"dotnet husky install"HuskyRun_WhenGitIsNotAvailable_ShouldShowHelpfulErrorMessage— hides the git binary to simulate it being absent from PATH, verifies the error output contains"not found"and"PATH"Type of change
Checklist
Original prompt
failed to execute command 'git'for dotnet project that works locally? #137✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.