mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-05 11:05:00 +00:00
enhance: include stdout in error popup when git process (in Exec
mode, we do not need to parse its output) exit with non-zero code
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
3377886bab
commit
e28b75b860
1 changed files with 26 additions and 29 deletions
|
@ -36,39 +36,14 @@ namespace SourceGit.Commands
|
||||||
|
|
||||||
public bool Exec()
|
public bool Exec()
|
||||||
{
|
{
|
||||||
|
Log?.AppendLine($"$ git {Args}\n");
|
||||||
|
|
||||||
var start = CreateGitStartInfo();
|
var start = CreateGitStartInfo();
|
||||||
var errs = new List<string>();
|
var errs = new List<string>();
|
||||||
var proc = new Process() { StartInfo = start };
|
var proc = new Process() { StartInfo = start };
|
||||||
|
|
||||||
Log?.AppendLine($"$ git {Args}\n");
|
proc.OutputDataReceived += (_, e) => HandleOutput(e.Data, errs);
|
||||||
|
proc.ErrorDataReceived += (_, e) => HandleOutput(e.Data, errs);
|
||||||
proc.OutputDataReceived += (_, e) =>
|
|
||||||
{
|
|
||||||
if (e.Data is { } line)
|
|
||||||
Log?.AppendLine(line);
|
|
||||||
};
|
|
||||||
|
|
||||||
proc.ErrorDataReceived += (_, e) =>
|
|
||||||
{
|
|
||||||
var line = e.Data ?? string.Empty;
|
|
||||||
Log?.AppendLine(line);
|
|
||||||
|
|
||||||
// Lines to hide in error message.
|
|
||||||
if (line.Length > 0)
|
|
||||||
{
|
|
||||||
if (line.StartsWith("remote: Enumerating objects:", StringComparison.Ordinal) ||
|
|
||||||
line.StartsWith("remote: Counting objects:", StringComparison.Ordinal) ||
|
|
||||||
line.StartsWith("remote: Compressing objects:", StringComparison.Ordinal) ||
|
|
||||||
line.StartsWith("Filtering content:", StringComparison.Ordinal) ||
|
|
||||||
line.StartsWith("hint:", StringComparison.Ordinal))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (REG_PROGRESS().IsMatch(line))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
errs.Add(line);
|
|
||||||
};
|
|
||||||
|
|
||||||
var dummy = null as Process;
|
var dummy = null as Process;
|
||||||
var dummyProcLock = new object();
|
var dummyProcLock = new object();
|
||||||
|
@ -217,6 +192,28 @@ namespace SourceGit.Commands
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleOutput(string line, List<string> errs)
|
||||||
|
{
|
||||||
|
line = line ?? string.Empty;
|
||||||
|
Log?.AppendLine(line);
|
||||||
|
|
||||||
|
// Lines to hide in error message.
|
||||||
|
if (line.Length > 0)
|
||||||
|
{
|
||||||
|
if (line.StartsWith("remote: Enumerating objects:", StringComparison.Ordinal) ||
|
||||||
|
line.StartsWith("remote: Counting objects:", StringComparison.Ordinal) ||
|
||||||
|
line.StartsWith("remote: Compressing objects:", StringComparison.Ordinal) ||
|
||||||
|
line.StartsWith("Filtering content:", StringComparison.Ordinal) ||
|
||||||
|
line.StartsWith("hint:", StringComparison.Ordinal))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (REG_PROGRESS().IsMatch(line))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
errs.Add(line);
|
||||||
|
}
|
||||||
|
|
||||||
[GeneratedRegex(@"\d+%")]
|
[GeneratedRegex(@"\d+%")]
|
||||||
private static partial Regex REG_PROGRESS();
|
private static partial Regex REG_PROGRESS();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue