Skip to content

Commit 6742b7a

Browse files
committed
Introduce silent execution method for ExternalCommandExecutor.
1 parent 4ce3a72 commit 6742b7a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/tooling/Elastic.Documentation.Tooling/ExternalCommands/ExternalCommandExecutor.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ protected void ExecIn(Dictionary<string, string> environmentVars, string binary,
2424
collector.EmitError("", $"Exit code: {result} while executing {binary} {string.Join(" ", args)} in {workingDirectory}");
2525
}
2626

27+
protected void ExecInSilent(Dictionary<string, string> environmentVars, string binary, params string[] args)
28+
{
29+
var arguments = new StartArguments(binary, args)
30+
{
31+
Environment = environmentVars,
32+
WorkingDirectory = workingDirectory.FullName,
33+
ConsoleOutWriter = NoopConsoleWriter.Instance
34+
};
35+
var result = Proc.Start(arguments);
36+
if (result.ExitCode != 0)
37+
collector.EmitError("", $"Exit code: {result.ExitCode} while executing {binary} {string.Join(" ", args)} in {workingDirectory}");
38+
}
39+
2740
protected string[] CaptureMultiple(string binary, params string[] args)
2841
{
2942
// Try 10 times to capture the output of the command, if it fails, we'll throw an exception on the last try

src/tooling/docs-builder/Tracking/LocalGitRepositoryTracker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public IEnumerable<GitChange> GetChangedFiles(string lookupPath)
1818
var defaultBranch = GetDefaultBranch();
1919
var commitChanges = CaptureMultiple("git", "diff", "--name-status", $"{defaultBranch}...HEAD", "--", $"./{lookupPath}");
2020
var localChanges = CaptureMultiple("git", "status", "--porcelain");
21-
_ = Capture("git", "stash", "push", "--", $"./{lookupPath}");
21+
ExecInSilent([], "git", "stash", "push", "--", $"./{lookupPath}");
2222
var localUnstagedChanges = CaptureMultiple("git", "stash", "show", "--name-status", "-u");
23-
_ = Capture("git", "stash", "pop");
23+
ExecInSilent([], "git", "stash", "pop");
2424

2525
return [.. GetCommitChanges(commitChanges), .. GetLocalChanges(localChanges), .. GetCommitChanges(localUnstagedChanges)];
2626
}

0 commit comments

Comments
 (0)