示例#1
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;
                }
            }
        }
示例#2
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;
                }
            }
        }
示例#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;
        }