Skip to content

Commit

Permalink
AheadBehindDataProvider: Return null on non-zero git exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
gerhardol authored and mstv committed Jul 4, 2021
1 parent cb46c4d commit 35632c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions GitCommands/Git/AheadBehindDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public AheadBehindDataProvider(Func<IExecutable> getGitExecutable)
"refs/heads/" + branchName
};

var result = GetGitExecutable().GetOutput(aheadBehindGitCommand, outputEncoding: encoding);
if (string.IsNullOrEmpty(result))
ExecutionResult result = GetGitExecutable().Execute(aheadBehindGitCommand, outputEncoding: encoding);
if (!result.ExitedSuccessfully || string.IsNullOrEmpty(result.StandardOutput))
{
return null;
}

var matches = _aheadBehindRegEx.Matches(result);
var matches = _aheadBehindRegEx.Matches(result.StandardOutput);
Dictionary<string, AheadBehindData> aheadBehindForBranchesData = new();
foreach (Match match in matches)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Setup()
_process.StandardError.Returns(x => _errorStreamReader);

_executable = Substitute.For<IExecutable>();
_executable.Start(Arg.Any<ArgumentString>(), Arg.Any<bool>(), Arg.Any<bool>(), Arg.Any<bool>(), Arg.Any<Encoding>()).Returns(x => _process);
_executable.Start(Arg.Any<ArgumentString>(), Arg.Any<bool>(), Arg.Any<bool>(), Arg.Any<bool>(), Arg.Any<Encoding>(), Arg.Any<bool>()).Returns(x => _process);

_provider = new AheadBehindDataProvider(() => _executable);
}
Expand Down

0 comments on commit 35632c7

Please sign in to comment.