Esempio n. 1
0
        private void Revert_Click(object sender, EventArgs e)
        {
            var args       = new ArgumentBuilder();
            var canExecute = true;

            if (_isMerge)
            {
                if (ParentsList.SelectedItems.Count == 0)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, _noneParentSelectedTextCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    canExecute = false;
                }
                else
                {
                    args.Add("-m " + (ParentsList.SelectedItems[0].Index + 1));
                }
            }

            if (checkAddReference.Checked)
            {
                args.Add("-x");
            }

            if (canExecute)
            {
                FormProcess.ShowDialog(this, GitCommandHelpers.CherryPickCmd(Revision.ObjectId, AutoCommit.Checked, args.ToString()));
                MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Esempio n. 2
0
        private void Revert_Click(object sender, EventArgs e)
        {
            var parentIndex = 0;

            if (_isMerge)
            {
                if (ParentsList.SelectedItems.Count != 1)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    parentIndex = ParentsList.SelectedItems[0].Index + 1;
                }
            }

            var  command = GitCommandHelpers.RevertCmd(Revision.ObjectId, AutoCommit.Checked, parentIndex);
            bool success = FormProcess.ShowDialog(this, process: null, arguments: command, Module.WorkingDir, input: null, useDialogSettings: true);

            if (!success)
            {
                return;
            }

            MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
            DialogResult = DialogResult.OK;
            Close();
        }
Esempio n. 3
0
        private void Revert_Click(object sender, EventArgs e)
        {
            List <string> argumentsList = new List <string>();
            bool          CanExecute    = true;

            if (IsMerge)
            {
                if (ParentsList.SelectedItems.Count == 0)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, _noneParentSelectedTextCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CanExecute = false;
                }
                else
                {
                    argumentsList.Add("-m " + (ParentsList.SelectedItems[0].Index + 1));
                }
            }

            if (checkAddReference.Checked)
            {
                argumentsList.Add("-x");
            }

            if (CanExecute)
            {
                FormProcess.ShowDialog(this, GitCommandHelpers.CherryPickCmd(Revision.Guid, AutoCommit.Checked, string.Join(" ", argumentsList.ToArray())));
                MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Esempio n. 4
0
        private void ApplyClick(object sender, EventArgs e)
        {
            FormProcess.ShowDialog(this, string.Format("stash apply \"{0}\"", Stashes.Text));

            MergeConflictHandler.HandleMergeConflicts(UICommands, this, false);

            UICommands.RepoChangedNotifier.Notify();

            Initialize();
        }
Esempio n. 5
0
 private void CheckMergeConflictsOnError(IWin32Window owner)
 {
     // Rebase failed -> special 'rebase' merge conflict
     if (Rebase.Checked && Module.InTheMiddleOfRebase())
     {
         UICommands.StartRebaseDialog(owner, null);
     }
     else if (Module.InTheMiddleOfAction())
     {
         MergeConflictHandler.HandleMergeConflicts(UICommands, owner);
     }
 }
Esempio n. 6
0
        private void OkClick(object sender, EventArgs e)
        {
            Settings.NoFastForwardMerge = noFastForward.Checked;

            var successfullyMerged = FormProcess.ShowDialog(this,
                                                            GitCommandHelpers.MergeBranchCmd(Branches.GetSelectedText(), fastForward.Checked, squash.Checked, noCommit.Checked, _NO_TRANSLATE_mergeStrategy.Text));

            var wasConflict = MergeConflictHandler.HandleMergeConflicts(UICommands, this);

            if (successfullyMerged || wasConflict)
            {
                UICommands.RepoChangedNotifier.Notify();
                Close();
            }
        }
Esempio n. 7
0
        private DialogResult EvaluateProcessDialogResults(IWin32Window owner, FormProcess process, bool stashed)
        {
            try
            {
                if (EvaluateResultsBasedOnSettings(stashed, process))
                {
                    return(DialogResult.OK);
                }
            }
            finally
            {
                if (stashed)
                {
                    bool?messageBoxResult = Settings.AutoPopStashAfterPull;
                    if (messageBoxResult == null)
                    {
                        DialogResult res = PSTaskDialog.cTaskDialog.MessageBox(
                            owner,
                            _applyShashedItemsAgainCaption.Text,
                            "",
                            _applyShashedItemsAgain.Text,
                            "",
                            "",
                            _dontShowAgain.Text,
                            PSTaskDialog.eTaskDialogButtons.YesNo,
                            PSTaskDialog.eSysIcons.Question,
                            PSTaskDialog.eSysIcons.Question);
                        messageBoxResult = (res == DialogResult.Yes);
                        if (PSTaskDialog.cTaskDialog.VerificationChecked)
                        {
                            Settings.AutoPopStashAfterPull = messageBoxResult;
                        }
                    }
                    if (ShouldStashPop(messageBoxResult ?? false, process, true))
                    {
                        FormProcess.ShowDialog(owner, Module, "stash pop");
                        MergeConflictHandler.HandleMergeConflicts(UICommands, owner, false);
                    }
                }

                ScriptManager.RunEventScripts(this, ScriptEvent.AfterPull);
            }

            return(DialogResult.No);
        }
Esempio n. 8
0
        private void OkClick(object sender, EventArgs e)
        {
            Module.EffectiveSettings.NoFastForwardMerge = noFastForward.Checked;
            AppSettings.DontCommitMerge = noCommit.Checked;

            var successfullyMerged = FormProcess.ShowDialog(this, GitCommandHelpers.MergeBranchCmd(Branches.GetSelectedText(),
                                                                                                   fastForward.Checked,
                                                                                                   squash.Checked,
                                                                                                   noCommit.Checked,
                                                                                                   _NO_TRANSLATE_mergeStrategy.Text,
                                                                                                   allowUnrelatedHistories.Checked,
                                                                                                   addMergeMessage.Checked ? mergeMessage.Text : null,
                                                                                                   addLogMessages.Checked ? (int)nbMessages.Value : (int?)null));

            var wasConflict = MergeConflictHandler.HandleMergeConflicts(UICommands, this, !noCommit.Checked);

            if (successfullyMerged || wasConflict)
            {
                UICommands.RepoChangedNotifier.Notify();
                Close();
            }
        }
        private void Revert_Click(object sender, EventArgs e)
        {
            var parentIndex = 0;

            if (_isMerge)
            {
                if (ParentsList.SelectedItems.Count != 1)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, _noneParentSelectedTextCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    parentIndex = ParentsList.SelectedItems[0].Index + 1;
                }
            }

            FormProcess.ShowDialog(this, GitCommandHelpers.RevertCmd(Revision.ObjectId, AutoCommit.Checked, parentIndex));
            MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
            DialogResult = DialogResult.OK;
            Close();
        }
Esempio n. 10
0
        private bool EvaluateResultsBasedOnSettings(bool stashed, FormProcess process)
        {
            if (!Module.InTheMiddleOfConflictedMerge() &&
                !Module.InTheMiddleOfRebase() &&
                (process != null && !process.ErrorOccurred()))
            {
                InitModules();
                return(true);
            }

            // Rebase failed -> special 'rebase' merge conflict
            if (Rebase.Checked && Module.InTheMiddleOfRebase())
            {
                UICommands.StartRebaseDialog(null);
                if (!Module.InTheMiddleOfConflictedMerge() &&
                    !Module.InTheMiddleOfRebase())
                {
                    return(true);
                }
            }
            else
            {
                MergeConflictHandler.HandleMergeConflicts(UICommands, this);
                if (!Module.InTheMiddleOfConflictedMerge() &&
                    !Module.InTheMiddleOfRebase())
                {
                    return(true);
                }
            }

            if (!AutoStash.Checked || !stashed || Module.InTheMiddleOfConflictedMerge() ||
                Module.InTheMiddleOfRebase())
            {
                return(true);
            }
            return(false);
        }
Esempio n. 11
0
        private void OkClick(object sender, EventArgs e)
        {
            Module.EffectiveSettings.NoFastForwardMerge = noFastForward.Checked;
            AppSettings.DontCommitMerge = noCommit.Checked;
            ScriptManager.RunEventScripts(this, ScriptEvent.BeforeMerge);

            string mergeMessagePath = null;

            if (addMergeMessage.Checked)
            {
                // [!] Do not reset the last commit message stored in AppSettings.LastCommitMessage

                _commitMessageManager.WriteCommitMessageToFile(mergeMessage.Text, CommitMessageType.Merge,
                                                               usingCommitTemplate: false,
                                                               ensureCommitMessageSecondLineEmpty: false);
                mergeMessagePath = _commitMessageManager.MergeMessagePath;
            }

            var command = GitCommandHelpers.MergeBranchCmd(Branches.GetSelectedText(),
                                                           fastForward.Checked,
                                                           squash.Checked,
                                                           noCommit.Checked,
                                                           _NO_TRANSLATE_mergeStrategy.Text,
                                                           allowUnrelatedHistories.Checked,
                                                           mergeMessagePath,
                                                           addLogMessages.Checked ? (int)nbMessages.Value : (int?)null);
            bool success = FormProcess.ShowDialog(this, process: null, arguments: command, Module.WorkingDir, input: null, useDialogSettings: true);

            var wasConflict = MergeConflictHandler.HandleMergeConflicts(UICommands, this, !noCommit.Checked);

            if (success || wasConflict)
            {
                ScriptManager.RunEventScripts(this, ScriptEvent.AfterMerge);
                UICommands.RepoChangedNotifier.Notify();
                Close();
            }
        }
Esempio n. 12
0
        private void Revert_Click(object sender, EventArgs e)
        {
            var args       = new ArgumentBuilder();
            var canExecute = true;

            if (_isMerge)
            {
                if (ParentsList.SelectedItems.Count == 0)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    canExecute = false;
                }
                else
                {
                    args.Add("-m " + (ParentsList.SelectedItems[0].Index + 1));
                }
            }

            if (checkAddReference.Checked)
            {
                args.Add("-x");
            }

            if (canExecute)
            {
                var  command = GitCommandHelpers.CherryPickCmd(Revision.ObjectId, AutoCommit.Checked, args.ToString());
                bool success = FormProcess.ShowDialog(this, process: null, arguments: command, Module.WorkingDir, input: null, useDialogSettings: true);
                if (!success)
                {
                    return;
                }

                MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Esempio n. 13
0
        private void Revert_Click(object sender, EventArgs e)
        {
            var args       = new ArgumentBuilder();
            var canExecute = true;

            if (_isMerge)
            {
                if (ParentsList.SelectedItems.Count == 0)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, TranslatedStrings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    canExecute = false;
                }
                else
                {
                    args.Add("-m " + (ParentsList.SelectedItems[0].Index + 1));
                }
            }

            if (checkAddReference.Checked)
            {
                args.Add("-x");
            }

            if (canExecute && Revision is not null)
            {
                var command = GitCommandHelpers.CherryPickCmd(Revision.ObjectId, AutoCommit.Checked, args.ToString());

                // Don't verify whether the command is successful.
                // If it fails, likely there is a conflict that needs to be resolved.
                FormProcess.ShowDialog(this, process: null, arguments: command, Module.WorkingDir, input: null, useDialogSettings: true);

                MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Esempio n. 14
0
        public DialogResult PullChanges(IWin32Window owner)
        {
            if (!ShouldPullChanges())
            {
                return(DialogResult.No);
            }

            DialogResult dr = ShouldRebaseMergeCommit();

            if (dr != DialogResult.Yes)
            {
                return(dr);
            }

            if (!Fetch.Checked && Branches.Text.IsNullOrWhiteSpace() && Module.IsDetachedHead())
            {
                int idx = PSTaskDialog.cTaskDialog.ShowCommandBox(
                    owner,
                    _notOnBranchCaption.Text,
                    _notOnBranchMainInstruction.Text,
                    _notOnBranch.Text,
                    _notOnBranchButtons.Text,
                    ShowCancelButton: true);

                switch (idx)
                {
                case 0:
                    if (!UICommands.StartCheckoutBranch(owner))
                    {
                        return(DialogResult.Cancel);
                    }

                    break;

                case -1:
                    return(DialogResult.Cancel);
                }
            }

            if (PullFromUrl.Checked && Directory.Exists(comboBoxPullSource.Text))
            {
                var path = comboBoxPullSource.Text;
                ThreadHelper.JoinableTaskFactory.Run(() => RepositoryHistoryManager.Remotes.AddAsMostRecentAsync(path));
            }

            var source = CalculateSource();

            if (!CalculateLocalBranch(source, out var curLocalBranch, out var curRemoteBranch))
            {
                return(DialogResult.No);
            }

            ScriptManager.RunEventScripts(this, ScriptEvent.BeforePull);

            var stashed = CalculateStashedValue(owner);

            using (var form = CreateFormProcess(source, curLocalBranch, curRemoteBranch))
            {
                if (!IsPullAll())
                {
                    form.Remote = source;
                }

                form.ShowDialog(owner);
                ErrorOccurred = form.ErrorOccurred();

                try
                {
                    bool aborted = form.DialogResult == DialogResult.Abort;
                    if (!aborted && !Fetch.Checked)
                    {
                        if (!ErrorOccurred)
                        {
                            if (!InitModules())
                            {
                                UICommands.UpdateSubmodules(owner);
                            }
                        }
                        else
                        {
                            CheckMergeConflictsOnError();
                        }
                    }
                }
                finally
                {
                    if (stashed)
                    {
                        PopStash();
                    }

                    ScriptManager.RunEventScripts(this, ScriptEvent.AfterPull);
                }
            }

            return(DialogResult.OK);

            bool ShouldPullChanges()
            {
                if (PullFromUrl.Checked && string.IsNullOrEmpty(comboBoxPullSource.Text))
                {
                    MessageBox.Show(this, _selectSourceDirectory.Text);
                    return(false);
                }

                if (PullFromRemote.Checked && string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text) && !IsPullAll())
                {
                    MessageBox.Show(this, _selectRemoteRepository.Text);
                    return(false);
                }

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

                return(true);
            }

            string CalculateSource()
            {
                if (PullFromUrl.Checked)
                {
                    return(comboBoxPullSource.Text);
                }

                LoadPuttyKey();
                return(IsPullAll() ? "--all" : _NO_TRANSLATE_Remotes.Text);
            }

            bool InitModules()
            {
                if (!File.Exists(_fullPathResolver.Resolve(".gitmodules")))
                {
                    return(false);
                }

                if (!IsSubmodulesInitialized())
                {
                    if (AskIfSubmodulesShouldBeInitialized())
                    {
                        UICommands.StartUpdateSubmodulesDialog(this);
                    }

                    return(true);
                }

                return(false);

                bool IsSubmodulesInitialized()
                {
                    // Fast submodules check
                    return(Module.GetSubmodulesLocalPaths()
                           .Select(submoduleName => Module.GetSubmodule(submoduleName))
                           .All(submodule => submodule.IsValidGitWorkingDir()));
                }

                bool AskIfSubmodulesShouldBeInitialized()
                {
                    return(MessageBox.Show(this, _questionInitSubmodules.Text, _questionInitSubmodulesCaption.Text,
                                           MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
                }
            }

            void CheckMergeConflictsOnError()
            {
                // Rebase failed -> special 'rebase' merge conflict
                if (Rebase.Checked && Module.InTheMiddleOfRebase())
                {
                    UICommands.StartTheContinueRebaseDialog(owner);
                }
                else if (Module.InTheMiddleOfAction())
                {
                    MergeConflictHandler.HandleMergeConflicts(UICommands, owner);
                }
            }

            void PopStash()
            {
                if (ErrorOccurred || Module.InTheMiddleOfAction())
                {
                    return;
                }

                bool?messageBoxResult = AppSettings.AutoPopStashAfterPull;

                if (messageBoxResult == null)
                {
                    DialogResult res = PSTaskDialog.cTaskDialog.MessageBox(
                        owner,
                        _applyStashedItemsAgainCaption.Text,
                        "",
                        _applyStashedItemsAgain.Text,
                        "",
                        "",
                        _dontShowAgain.Text,
                        PSTaskDialog.eTaskDialogButtons.YesNo,
                        PSTaskDialog.eSysIcons.Question,
                        PSTaskDialog.eSysIcons.Question);
                    messageBoxResult = res == DialogResult.Yes;
                    if (PSTaskDialog.cTaskDialog.VerificationChecked)
                    {
                        AppSettings.AutoPopStashAfterPull = messageBoxResult;
                    }
                }

                if ((bool)messageBoxResult)
                {
                    UICommands.StashPop(owner);
                }
            }
        }
Esempio n. 15
0
        public DialogResult PullChanges(IWin32Window owner)
        {
            if (!ShouldPullChanges())
            {
                return(DialogResult.No);
            }

            UpdateSettingsDuringPull();

            DialogResult dr = ShouldRebaseMergeCommit();

            if (dr != DialogResult.Yes)
            {
                return(dr);
            }

            if (!Fetch.Checked && string.IsNullOrWhiteSpace(Branches.Text) && Module.IsDetachedHead())
            {
                int dialogResult = -1;

                using var dialog = new TaskDialog
                      {
                          OwnerWindowHandle = owner.Handle,
                          Text            = _notOnBranch.Text,
                          InstructionText = Strings.ErrorInstructionNotOnBranch,
                          Caption         = Strings.ErrorCaptionNotOnBranch,
                          StandardButtons = TaskDialogStandardButtons.Cancel,
                          Icon            = TaskDialogStandardIcon.Error,
                          Cancelable      = true,
                      };
                var btnCheckout = new TaskDialogCommandLink("Checkout", null, Strings.ButtonCheckoutBranch);
                btnCheckout.Click += (s, e) =>
                {
                    dialogResult = 0;
                    dialog.Close();
                };
                var btnContinue = new TaskDialogCommandLink("Continue", null, Strings.ButtonContinue);
                btnContinue.Click += (s, e) =>
                {
                    dialogResult = 1;
                    dialog.Close();
                };
                dialog.Controls.Add(btnCheckout);
                dialog.Controls.Add(btnContinue);

                dialog.Show();

                switch (dialogResult)
                {
                case 0:
                    if (!UICommands.StartCheckoutBranch(owner))
                    {
                        return(DialogResult.Cancel);
                    }

                    break;

                case -1:
                    return(DialogResult.Cancel);
                }
            }

            if (PullFromUrl.Checked && Directory.Exists(comboBoxPullSource.Text))
            {
                var path = comboBoxPullSource.Text;
                ThreadHelper.JoinableTaskFactory.Run(() => RepositoryHistoryManager.Remotes.AddAsMostRecentAsync(path));
            }

            var source = CalculateSource();

            if (!CalculateLocalBranch(source, out var curLocalBranch, out var curRemoteBranch))
            {
                return(DialogResult.No);
            }

            executeBeforeScripts();

            var stashed = CalculateStashedValue(owner);

            using (var form = CreateFormProcess(source, curLocalBranch, curRemoteBranch))
            {
                if (!IsPullAll())
                {
                    form.Remote = source;
                }

                form.ShowDialog(owner);
                ErrorOccurred = form.ErrorOccurred();

                bool executeScripts = false;
                try
                {
                    bool aborted = form.DialogResult == DialogResult.Abort;
                    executeScripts = !aborted && !ErrorOccurred;

                    if (!aborted && !Fetch.Checked)
                    {
                        if (!ErrorOccurred)
                        {
                            if (!InitModules())
                            {
                                UICommands.UpdateSubmodules(owner);
                            }
                        }
                        else
                        {
                            executeScripts |= CheckMergeConflictsOnError();
                        }
                    }
                }
                finally
                {
                    if (stashed)
                    {
                        PopStash();
                    }

                    if (executeScripts)
                    {
                        executeAfterScripts();
                    }
                }
            }

            return(DialogResult.OK);

            bool ShouldPullChanges()
            {
                if (PullFromUrl.Checked && string.IsNullOrEmpty(comboBoxPullSource.Text))
                {
                    MessageBox.Show(this, _selectSourceDirectory.Text, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                if (PullFromRemote.Checked && string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text) && !IsPullAll())
                {
                    MessageBox.Show(this, _selectRemoteRepository.Text, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                if (!Fetch.Checked && Branches.Text == "*")
                {
                    MessageBox.Show(this, _fetchAllBranchesCanOnlyWithFetch.Text, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                return(true);
            }

            string CalculateSource()
            {
                if (PullFromUrl.Checked)
                {
                    return(comboBoxPullSource.Text);
                }

                LoadPuttyKey();
                return(IsPullAll() ? "--all" : _NO_TRANSLATE_Remotes.Text);
            }

            bool InitModules()
            {
                if (!File.Exists(_fullPathResolver.Resolve(".gitmodules")))
                {
                    return(false);
                }

                if (!IsSubmodulesInitialized())
                {
                    if (AskIfSubmodulesShouldBeInitialized())
                    {
                        UICommands.StartUpdateSubmodulesDialog(this);
                    }

                    return(true);
                }

                return(false);

                bool IsSubmodulesInitialized()
                {
                    // Fast submodules check
                    return(Module.GetSubmodulesLocalPaths()
                           .Select(submoduleName => Module.GetSubmodule(submoduleName))
                           .All(submodule => submodule.IsValidGitWorkingDir()));
                }

                bool AskIfSubmodulesShouldBeInitialized()
                {
                    return(MessageBox.Show(this, _questionInitSubmodules.Text, _questionInitSubmodulesCaption.Text,
                                           MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
                }
            }

            bool CheckMergeConflictsOnError()
            {
                // Rebase failed -> special 'rebase' merge conflict
                if (Rebase.Checked && Module.InTheMiddleOfRebase())
                {
                    return(UICommands.StartTheContinueRebaseDialog(owner));
                }
                else if (Module.InTheMiddleOfAction())
                {
                    return(MergeConflictHandler.HandleMergeConflicts(UICommands, owner));
                }

                return(false);
            }

            void PopStash()
            {
                if (ErrorOccurred || Module.InTheMiddleOfAction())
                {
                    return;
                }

                bool?messageBoxResult = AppSettings.AutoPopStashAfterPull;

                if (messageBoxResult == null)
                {
                    using var dialog = new TaskDialog
                          {
                              OwnerWindowHandle = owner.Handle,
                              Text               = _applyStashedItemsAgain.Text,
                              Caption            = _applyStashedItemsAgainCaption.Text,
                              StandardButtons    = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No,
                              Icon               = TaskDialogStandardIcon.Information,
                              FooterCheckBoxText = _dontShowAgain.Text,
                              FooterIcon         = TaskDialogStandardIcon.Information,
                              StartupLocation    = TaskDialogStartupLocation.CenterOwner,
                          };

                    messageBoxResult = dialog.Show() == TaskDialogResult.Yes;

                    if (dialog.FooterCheckBoxChecked == true)
                    {
                        AppSettings.AutoPopStashAfterPull = messageBoxResult;
                    }
                }

                if ((bool)messageBoxResult)
                {
                    UICommands.StashPop(owner);
                }
            }

            void executeBeforeScripts()
            {
                // Request to pull/merge in addition to the fetch
                if (!Fetch.Checked)
                {
                    ScriptManager.RunEventScripts(this, ScriptEvent.BeforePull);
                }

                ScriptManager.RunEventScripts(this, ScriptEvent.BeforeFetch);
            }

            void executeAfterScripts()
            {
                ScriptManager.RunEventScripts(this, ScriptEvent.AfterFetch);

                // Request to pull/merge in addition to the fetch
                if (!Fetch.Checked)
                {
                    ScriptManager.RunEventScripts(this, ScriptEvent.AfterPull);
                }
            }
        }
Esempio n. 16
0
        private DialogResult OkClick()
        {
            GitCheckoutBranchCmd cmd = new GitCheckoutBranchCmd(Branches.Text.Trim(), Remotebranch.Checked);

            if (Remotebranch.Checked)
            {
                if (rbCreateBranchWithCustomName.Checked)
                {
                    cmd.NewBranchName   = txtCustomBranchName.Text.Trim();
                    cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.Create;
                    if (cmd.NewBranchName.IsNullOrWhiteSpace())
                    {
                        MessageBox.Show(_customBranchNameIsEmpty.Text, Text);
                        DialogResult = DialogResult.None;
                        return(DialogResult.None);
                    }
                    if (!Module.CheckBranchFormat(cmd.NewBranchName))
                    {
                        MessageBox.Show(string.Format(_customBranchNameIsNotValid.Text, cmd.NewBranchName), Text);
                        DialogResult = DialogResult.None;
                        return(DialogResult.None);
                    }
                }
                else if (rbResetBranch.Checked)
                {
                    cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.Reset;
                    cmd.NewBranchName   = _localBranchName;
                }
                else
                {
                    cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.DontCreate;
                    cmd.NewBranchName   = null;
                }
            }

            LocalChangesAction changes = ChangesMode;

            AppSettings.CheckoutBranchAction = changes;

            if ((Visible || AppSettings.UseDefaultCheckoutBranchAction) && IsThereUncommittedChanges())
            {
                cmd.LocalChanges = changes;
            }
            else
            {
                cmd.LocalChanges = LocalChangesAction.DontChange;
            }

            IWin32Window owner = Visible ? this : Owner;

            bool stash = false;

            if (changes == LocalChangesAction.Stash)
            {
                if (_isDirtyDir == null && Visible)
                {
                    _isDirtyDir = Module.IsDirtyDir();
                }
                stash = _isDirtyDir == true;
                if (stash)
                {
                    UICommands.Stash(owner);
                }
            }

            if (UICommands.StartCommandLineProcessDialog(cmd, owner))
            {
                if (stash)
                {
                    bool?messageBoxResult = AppSettings.AutoPopStashAfterCheckoutBranch;
                    if (messageBoxResult == null)
                    {
                        DialogResult res = PSTaskDialog.cTaskDialog.MessageBox(
                            this,
                            _applyShashedItemsAgainCaption.Text,
                            "",
                            _applyShashedItemsAgain.Text,
                            "",
                            "",
                            _dontShowAgain.Text,
                            PSTaskDialog.eTaskDialogButtons.YesNo,
                            PSTaskDialog.eSysIcons.Question,
                            PSTaskDialog.eSysIcons.Question);
                        messageBoxResult = (res == DialogResult.Yes);
                        if (PSTaskDialog.cTaskDialog.VerificationChecked)
                        {
                            AppSettings.AutoPopStashAfterCheckoutBranch = messageBoxResult;
                        }
                    }
                    if (messageBoxResult ?? false)
                    {
                        FormProcess.ShowDialog(this, Module, "stash pop");
                        MergeConflictHandler.HandleMergeConflicts(UICommands, this, false);
                    }
                }
                return(DialogResult.OK);
            }

            return(DialogResult.None);
        }