/// <summary> /// Callback that handles process printing to stdout /// </summary> private void PStdout(String message) { textStdout.AppendText(ClassUtils.ToPlainAscii(message) + Environment.NewLine); // Keep the newly added text visible textStdout.SelectionStart = textStdout.TextLength; textStdout.ScrollToCaret(); }
/// <summary> /// Callback that handles process printing to stderr. /// Prints the stderr to a log window. /// </summary> private void PStderr(String message) { // Remove CSI [ or ESC [ + single character sequence if (message.StartsWith("\u001b[")) { message = message.Remove(0, 3); } // This is a workaround for Linux Mono: // On Windows, when we clone a remote repo, we receive each status line as a separate message // On Linux, it is all clumped together without any newlines (or 0A), so we inject them if (ClassUtils.IsMono()) { // A bit of a hack since we simply hard-code recognized types of messages. Oh, well... message = message.Replace("remote:", Environment.NewLine + "remote:"); message = message.Replace("Receiving", Environment.NewLine + "Receiving"); message = message.Replace("Resolving", Environment.NewLine + "Resolving"); } textStdout.AppendText(ClassUtils.ToPlainAscii(message) + Environment.NewLine, Color.Red); // Keep the newly added text visible textStdout.SelectionStart = textStdout.TextLength; textStdout.ScrollToCaret(); // This hack recognizes a common problem where the host RSA key was not added to the list // of known hosts. Help the user by telling him that and (on Windows) offering to open the // Manage Keys dialog. if (message.Contains("key fingerprint is")) { // On Linux / Mono, we don't have a Manage SSH dialog if (ClassUtils.IsMono()) { MessageBox.Show(@"The remote server RSA key was not added to the list of known hosts.", @"Host Key error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { DialogResult response = MessageBox.Show(@"The remote server RSA key was not added to the list of known hosts." + Environment.NewLine + @"Would you like to open the Manage SSH Keys dialog to add the host in the Remote Keys tab?", @"Host Key error", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (response == DialogResult.Yes) { FormSSH formSsh = new FormSSH(); formSsh.ShowDialog(); } } } // This hack recognizes a common HTTPS authentication error message if (message.Contains(@"fatal: Authentication failed for 'https:")) { MessageBox.Show(@"The remote server refused to authenticate you." + Environment.NewLine + @"You need to set your full HTTPS credentials (user name and password) to access this repo.", @"HTTPS Authentication error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // Append the stderr stream message to a log window App.PrintLogMessage("stderr: " + message, MessageType.Error); }