Example #1
0
        private void UpdateBranches(RemoteActionResult <IList <GitRef> > branchList)
        {
            Cursor = Cursors.Default;

            if (branchList.HostKeyFail)
            {
                string remoteUrl = _NO_TRANSLATE_From.Text;

                if (FormRemoteProcess.AskForCacheHostkey(this, Module, remoteUrl))
                {
                    LoadBranches();
                }
            }
            else if (branchList.AuthenticationFail)
            {
                string loadedKey;
                if (FormPuttyError.AskForKey(this, out loadedKey))
                {
                    LoadBranches();
                }
            }
            else
            {
                string text = Branches.Text;
                Branches.DataSource = branchList.Result;
                if (branchList.Result.Any(a => a.LocalName == text))
                {
                    Branches.Text = text;
                }
            }
        }
Example #2
0
        private void UpdateBranches(RemoteActionResult <IReadOnlyList <IGitRef> > branchList)
        {
            Cursor = Cursors.Default;

            if (branchList.HostKeyFail)
            {
                string remoteUrl = _NO_TRANSLATE_From.Text;

                if (FormRemoteProcess.AskForCacheHostkey(this, Module, remoteUrl))
                {
                    LoadBranches();
                }
            }
            else if (branchList.AuthenticationFail)
            {
                if (FormPuttyError.AskForKey(this, out _))
                {
                    LoadBranches();
                }
            }
            else
            {
                string        text  = _NO_TRANSLATE_Branches.Text;
                List <string> names = _defaultBranchItems.Concat(branchList.Result.Select(o => o.LocalName)).ToList();
                _NO_TRANSLATE_Branches.DataSource = names;
                if (names.Any(a => a == text))
                {
                    _NO_TRANSLATE_Branches.Text = text;
                }
            }
        }
Example #3
0
        private void ProcessHeads(string remote, IList <GitRef> localHeads, RemoteActionResult <IList <GitRef> > remoteHeads)
        {
            Cursor = Cursors.Default;
            if (remoteHeads.HostKeyFail)
            {
                string remoteUrl;

                remoteUrl = Module.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                if (string.IsNullOrEmpty(remoteUrl))
                {
                    remoteUrl = remote;
                }

                if (FormRemoteProcess.AskForCacheHostkey(this, Module, remoteUrl))
                {
                    LoadMultiBranchViewData(remote, localHeads);
                }
            }
            else if (remoteHeads.AuthenticationFail)
            {
                string loadedKey;
                if (FormPuttyError.AskForKey(this, out loadedKey))
                {
                    LoadMultiBranchViewData(remote, localHeads);
                }
            }
            else
            {
                // Add all the local branches.
                foreach (var head in localHeads)
                {
                    DataRow row = _branchTable.NewRow();
                    row["Force"]  = false;
                    row["Delete"] = false;
                    row["Local"]  = head.Name;

                    string remoteName;
                    if (head.Remote == remote)
                    {
                        remoteName = head.MergeWith ?? head.Name;
                    }
                    else
                    {
                        remoteName = head.Name;
                    }

                    row["Remote"] = remoteName;
                    bool newAtRemote = remoteHeads.Result.Any(h => h.Name == remoteName);
                    row["New"]  = newAtRemote ? _no.Text : _yes.Text;
                    row["Push"] = newAtRemote;

                    _branchTable.Rows.Add(row);
                }

                // Offer to delete all the left over remote branches.
                foreach (var remoteHead in remoteHeads.Result)
                {
                    GitRef head = remoteHead;
                    if (localHeads.All(h => h.Name != head.Name))
                    {
                        DataRow row = _branchTable.NewRow();
                        row["Local"]  = null;
                        row["Remote"] = remoteHead.Name;
                        row["New"]    = _no.Text;
                        row["Push"]   = false;
                        row["Force"]  = false;
                        row["Delete"] = false;
                        _branchTable.Rows.Add(row);
                    }
                }
            }
            BranchGrid.Enabled = true;
        }
Example #4
0
        protected override bool HandleOnExit(ref bool isError)
        {
            if (_restart)
            {
                Retry();
                return(true);
            }

            // An error occurred!
            if (isError && Plink)
            {
                var output = GetOutputString();

                // there might be another error, this condition is too weak

                /*
                 * if (output.Contains("successfully authenticated"))
                 * {
                 *  isError = false;
                 *  return false;
                 * }
                 */

                // If the authentication failed because of a missing key, ask the user to supply one.
                if (output.Contains("FATAL ERROR") && output.Contains("authentication"))
                {
                    if (FormPuttyError.AskForKey(this, out var loadedKey))
                    {
                        // To prevent future authentication errors, save this key for this remote.
                        if (!string.IsNullOrEmpty(loadedKey) && !string.IsNullOrEmpty(Remote) &&
                            string.IsNullOrEmpty(Commands.Module.GetSetting("remote.{0}.puttykeyfile")))
                        {
                            Commands.Module.SetPathSetting(string.Format("remote.{0}.puttykeyfile", Remote), loadedKey);
                        }

                        // Retry the command.
                        Retry();
                        return(true);
                    }
                }

                if (output.Contains("the server's host key is not cached in the registry", StringComparison.OrdinalIgnoreCase))
                {
                    string remoteUrl;

                    if (string.IsNullOrEmpty(_urlTryingToConnect))
                    {
                        remoteUrl = Commands.Module.GetSetting(string.Format(SettingKeyString.RemoteUrl, Remote));
                        if (string.IsNullOrEmpty(remoteUrl))
                        {
                            remoteUrl = Remote;
                        }
                    }
                    else
                    {
                        remoteUrl = _urlTryingToConnect;
                    }

                    if (AskForCacheHostkey(this, remoteUrl))
                    {
                        Retry();
                        return(true);
                    }
                }
            }

            return(base.HandleOnExit(ref isError));
        }