public void DeleteForce()
            {
                var branchHead = CreateBranchRef(UICommands.Module, FullPath);
                var cmd        = new GitDeleteBranchCmd(new[] { branchHead }, true);

                UICommands.StartCommandLineProcessDialog(cmd, null);
            }
            public void DeleteAllForce()
            {
                var branches    = Nodes.DepthEnumerator <LocalBranchNode>();
                var branchHeads =
                    branches.Select(branch => CreateBranchRef(UICommands.Module, branch.FullPath));
                var cmd = new GitDeleteBranchCmd(branchHeads.ToList(), true);

                UICommands.StartCommandLineProcessDialog(cmd, null);
            }
예제 #3
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                var selectedBranches = Branches.GetSelectedBranches().ToArray();

                if (!selectedBranches.Any())
                {
                    return;
                }

                if (_currentBranch != null && selectedBranches.Any(branch => branch.Name == _currentBranch))
                {
                    MessageBox.Show(this, string.Format(_cannotDeleteCurrentBranchMessage.Text, _currentBranch), _deleteBranchCaption.Text);
                    return;
                }

                // always treat branches as unmerged if there is no current branch (HEAD is detached)
                var hasUnmergedBranches = _currentBranch == null || selectedBranches.Any(branch => !_mergedBranches.Contains(branch.Name));

                // we could show yes/no dialog and set forcing checkbox automatically, but more safe way is asking user to do it himself
                if (hasUnmergedBranches && !ForceDelete.Checked)
                {
                    MessageBox.Show(this, _deleteUnmergedBranchForcingSuggestion.Text, _deleteBranchCaption.Text);
                    return;
                }

                // ask for confirmation to delete unmerged branch that may cause loosing commits
                // (actually we could check if there are another branches pointing to that commit)
                if (hasUnmergedBranches &&
                    MessageBox.Show(this, _deleteBranchQuestion.Text, _deleteBranchCaption.Text, MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }

                var cmd = new GitDeleteBranchCmd(selectedBranches, ForceDelete.Checked);
                UICommands.StartCommandLineProcessDialog(this, cmd);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }

            Close();
        }
예제 #4
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show(this, _deleteBranchQuestion.Text, _deleteBranchCaption.Text, MessageBoxButtons.YesNo) ==
                    DialogResult.Yes)
                {
                    GitDeleteBranchCmd cmd = new GitDeleteBranchCmd();
                    cmd.Force = ForceDelete.Checked;
                    foreach (GitHead head in Branches.GetSelectedBranches())
                    {
                        cmd.AddBranch(head.Name, head.IsRemote);
                    }

                    GitUICommands.Instance.StartCommandLineProcessDialog(cmd, this);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            Close();
        }