diff --git a/src/app/GitUI/HelperDialogs/FormProcess.cs b/src/app/GitUI/HelperDialogs/FormProcess.cs index 789321fbd57..804f843b7d0 100644 --- a/src/app/GitUI/HelperDialogs/FormProcess.cs +++ b/src/app/GitUI/HelperDialogs/FormProcess.cs @@ -13,8 +13,6 @@ namespace GitUI.HelperDialogs public partial class FormProcess : FormStatus { public string Remote { get; set; } - public string ProcessString { get; } - public string ProcessArguments { get; set; } public string? ProcessInput { get; } public readonly string WorkingDirectory; public HandleOnExit? HandleOnExitCallback { get; set; } diff --git a/src/app/GitUI/HelperDialogs/FormStatus.cs b/src/app/GitUI/HelperDialogs/FormStatus.cs index 1882054681d..20e755d0b11 100644 --- a/src/app/GitUI/HelperDialogs/FormStatus.cs +++ b/src/app/GitUI/HelperDialogs/FormStatus.cs @@ -1,5 +1,8 @@ +using System.Diagnostics; using GitCommands; using GitExtensions.Extensibility.Git; +using GitExtUtils; +using GitUI.Models; using GitUI.Properties; using GitUI.UserControls; using Microsoft.WindowsAPICodePack.Taskbar; @@ -51,6 +54,9 @@ public FormStatus(IGitUICommands commands, ConsoleOutputControl? consoleOutput, InitializeComplete(); } + public string? ProcessString { get; protected init; } + public string? ProcessArguments { get; set; } + /// /// Clean up any resources being used. /// @@ -121,7 +127,7 @@ public static void ShowErrorDialog(IWin32Window owner, IGitUICommands commands, form.StartPosition = FormStartPosition.CenterParent; // We know that an operation (whatever it may have been) has failed, so set the error state. - form.Done(false); + form.Done(isSuccess: false); form.ShowDialog(owner); } @@ -156,6 +162,18 @@ private protected void Done(bool isSuccess) { try { + _errorOccurred = !isSuccess; + + try + { + RunProcessInfo runProcessInfo = new(ProcessString, ProcessArguments, GetOutputString(), DateTime.Now); + UICommands.GetRequiredService().Trace(runProcessInfo); + } + catch (Exception exception) + { + Trace.WriteLine(exception); + } + AppendMessage("Done"); ProgressBar.Visible = false; Ok.Enabled = true; @@ -167,16 +185,15 @@ private protected void Done(bool isSuccess) Bitmap image = isSuccess ? Images.StatusBadgeSuccess : Images.StatusBadgeError; SetIcon(image); - _errorOccurred = !isSuccess; - if (isSuccess && (_useDialogSettings && AppSettings.CloseProcessDialog)) { Close(); } } - catch (ConEmu.WinForms.GuiMacroExecutor.GuiMacroException) + catch (ConEmu.WinForms.GuiMacroExecutor.GuiMacroException guiMacroException) { // Do nothing + Trace.WriteLine(guiMacroException); } } @@ -242,7 +259,7 @@ private void Abort_Click(object sender, EventArgs e) { AbortCallback?.Invoke(this); OutputLog.Append(Environment.NewLine + "Aborted"); // TODO: write to display control also, if we pull the function up to this base class - Done(false); + Done(isSuccess: false); DialogResult = DialogResult.Abort; } catch diff --git a/tests/app/IntegrationTests/UI.IntegrationTests/GlobalServiceContainer.cs b/tests/app/IntegrationTests/UI.IntegrationTests/GlobalServiceContainer.cs index 2bc392d5f03..d39d49678d8 100644 --- a/tests/app/IntegrationTests/UI.IntegrationTests/GlobalServiceContainer.cs +++ b/tests/app/IntegrationTests/UI.IntegrationTests/GlobalServiceContainer.cs @@ -4,6 +4,7 @@ using GitExtUtils; using GitUI; using GitUI.Hotkey; +using GitUI.Models; using GitUI.ScriptsEngine; using NSubstitute; using ResourceManager; @@ -15,6 +16,9 @@ public static class GlobalServiceContainer public static ServiceContainer CreateDefaultMockServiceContainer() { ServiceContainer serviceContainer = new(); + + serviceContainer.AddService(Substitute.For()); + serviceContainer.AddService(Substitute.For()); serviceContainer.AddService(Substitute.For()); serviceContainer.AddService(Substitute.For());