コード例 #1
0
        private void OnExit(object state)
        {
            if (restart)
            {
                Reset();
                ProcessCallback(this);
                return;
            }

            bool isError;

            try
            {
                // An error occurred!
                if (gitCommand != null && gitCommand.ExitCode != 0)
                {
                    isError = true;

                    // TODO: This Plink stuff here seems misplaced. Is there a better
                    // home for all of this stuff? For example, if I had a label called pull,
                    // we could end up in this code incorrectly.
                    if (Plink)
                    {
                        if (ProcessArguments.ToLower().Contains("pull") || ProcessArguments.ToLower().Contains("push") || ProcessArguments.ToLower().Contains("plink") || ProcessArguments.ToLower().Contains("tortoiseplink") || ProcessArguments.ToLower().Contains("remote") || ProcessString.ToLower().Contains("clone") || ProcessArguments.ToLower().Contains("clone"))
                        {
                            if (OutputString.ToString().Contains("successfully authenticated"))
                            {
                                isError = false;
                            }

                            if (OutputString.ToString().Contains("FATAL ERROR") && OutputString.ToString().Contains("authentication"))
                            {
                                var puttyError = new FormPuttyError();
                                puttyError.ShowDialog();
                                if (puttyError.RetryProcess)
                                {
                                    Reset();
                                    ProcessCallback(this);
                                    return;
                                }
                            }
                            if (OutputString.ToString().ToLower().Contains("the server's host key is not cached in the registry") && !string.IsNullOrEmpty(UrlTryingToConnect))
                            {
                                if (MessageBox.Show("The server's host key is not cached in the registry.\n\nDo you want to trust this host key and then try again?", "SSH", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                                {
                                    GitCommandHelpers.RunRealCmdDetached(
                                        "cmd.exe",
                                        string.Format("/k \"\"{0}\" -T \"{1}\"\"", Settings.Plink, UrlTryingToConnect));

                                    Reset();
                                    ProcessCallback(this);
                                    return;
                                }
                            }
                        }
                    }
                }
                else
                {
                    isError = false;
                }
            }
            catch
            {
                isError = true;
            }

            Done(!isError);
        }