Skip to content

Commit

Permalink
diagnose: avoid poluting stderr stream in Git diagnostic (#1590)
Browse files Browse the repository at this point in the history
Avoid poluting the standard error stream with a 'fatal' Git error
message during the Git diagnostic run as part of the `diagnose` command.

When checking if we are inside of a Git repo we should be using an
explicit check for `IGit::IsInsideRepository` rather than trying to get
the current repo path and checking for null.
  • Loading branch information
mjcheetham committed Apr 17, 2024
2 parents 25f0950 + eb6cd02 commit 8f00c5e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/shared/Core/Diagnostics/GitDiagnostic.cs
Expand Up @@ -19,9 +19,16 @@ protected override Task<bool> RunInternalAsync(StringBuilder log, IList<string>
log.AppendLine($"Git version is '{gitVersion.OriginalString}'");

log.Append("Locating current repository...");
string thisRepo =CommandContext.Git.GetCurrentRepository();
if (!CommandContext.Git.IsInsideRepository())
{
log.AppendLine("Not inside a Git repository.");
}
else
{
string thisRepo = CommandContext.Git.GetCurrentRepository();
log.AppendLine($"Git repository at '{thisRepo}'");
}
log.AppendLine(" OK");
log.AppendLine(thisRepo is null ? "Not inside a Git repository." : $"Git repository at '{thisRepo}'");

log.Append("Listing all Git configuration...");
ChildProcess configProc = CommandContext.Git.CreateProcess("config --list --show-origin");
Expand Down

0 comments on commit 8f00c5e

Please sign in to comment.