GitUI.FormPull.PullClick C# (CSharp) Méthode

PullClick() private méthode

private PullClick ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Résultat void
        private void PullClick(object sender, EventArgs e)
        {
            if (PullFromUrl.Checked && string.IsNullOrEmpty(PullSource.Text))
            {
                MessageBox.Show(_selectSourceDirectory.Text);
                return;
            }
            if (PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text))
            {
                MessageBox.Show(_selectRemoteRepository.Text);
                return;
            }

            if (!Fetch.Checked && Branches.Text == "*")
            {
                MessageBox.Show(_fetchAllBranchesCanOnlyWithFetch.Text);
                return;
            }

            if (Merge.Checked)
                Settings.PullMerge = "merge";
            if (Rebase.Checked)
                Settings.PullMerge = "rebase";
            if (Fetch.Checked)
                Settings.PullMerge = "fetch";

            Settings.AutoStash = AutoStash.Checked;

            Repositories.RepositoryHistory.AddMostRecentRepository(PullSource.Text);

            string source;

            if (PullFromUrl.Checked)
                source = PullSource.Text;
            else
            {
                LoadPuttyKey();
                source = Remotes.Text;
            }

            var stashed = false;
            if (AutoStash.Checked && GitCommands.GitCommands.GitStatus(false).Count > 0)
            {
                new FormProcess("stash save").ShowDialog();
                stashed = true;
            }

            FormProcess process = null;
            if (Fetch.Checked)
            {
                process = new FormProcess(GitCommands.GitCommands.FetchCmd(source, Branches.Text, null));
            }
            else
            {
                string localBranch = GitCommands.GitCommands.GetSelectedBranch();
                if (localBranch.Equals("(no branch)", StringComparison.OrdinalIgnoreCase))
                    localBranch = null;

                if (Merge.Checked)
                    process = new FormProcess(GitCommands.GitCommands.PullCmd(source, Branches.Text, localBranch, false));
                else if (Rebase.Checked)
                    process = new FormProcess(GitCommands.GitCommands.PullCmd(source, Branches.Text, localBranch, true));
            }

            if (process != null)
                process.ShowDialog();

            if (!GitCommands.GitCommands.InTheMiddleOfConflictedMerge() &&
                !GitCommands.GitCommands.InTheMiddleOfRebase() &&
                (process != null && !process.ErrorOccured()))
                Close();

            // Rebase failed -> special 'rebase' merge conflict
            if (Rebase.Checked && GitCommands.GitCommands.InTheMiddleOfRebase())
            {
                GitUICommands.Instance.StartRebaseDialog(null);
                if (!GitCommands.GitCommands.InTheMiddleOfConflictedMerge() &&
                    !GitCommands.GitCommands.InTheMiddleOfRebase())
                    Close();
            }
            else
            {
                MergeConflictHandler.HandleMergeConflicts();
                if (!GitCommands.GitCommands.InTheMiddleOfConflictedMerge() &&
                    !GitCommands.GitCommands.InTheMiddleOfRebase())
                    Close();
            }

            if (!AutoStash.Checked || !stashed || GitCommands.GitCommands.InTheMiddleOfConflictedMerge() ||
                GitCommands.GitCommands.InTheMiddleOfRebase())
                return;

            if (MessageBox.Show(_applyShashedItemsAgain.Text, _applyShashedItemsAgainCaption.Text,
                                MessageBoxButtons.YesNo) != DialogResult.Yes)
                return;

            new FormProcess("stash pop").ShowDialog();

            MergeConflictHandler.HandleMergeConflicts();
        }