public static ArgumentString CheckoutCmd(string branchOrRevisionName, LocalChangesAction changesAction) { return(new GitArgumentBuilder("checkout") { { changesAction == LocalChangesAction.Merge, "--merge" }, { changesAction == LocalChangesAction.Reset, "--force" }, branchOrRevisionName.Quote() }); }
public static string CheckoutCmd(string branchOrRevisionName, LocalChangesAction changesAction) { var args = new ArgumentBuilder { "checkout", { changesAction == LocalChangesAction.Merge, "--merge" }, { changesAction == LocalChangesAction.Reset, "--force" }, branchOrRevisionName.Quote() }; return(args.ToString()); }
public GitCheckoutBranchCmd( string branchName, bool remote, LocalChangesAction localChanges = LocalChangesAction.DontChange, CheckoutNewBranchMode newBranchMode = CheckoutNewBranchMode.DontCreate, string newBranchName = null) { BranchName = branchName; Remote = remote; LocalChanges = localChanges == LocalChangesAction.Stash ? LocalChangesAction.DontChange : localChanges; NewBranchMode = newBranchMode; NewBranchName = newBranchName; }
public static string CheckoutCmd(string branchOrRevisionName, LocalChangesAction changesAction) { string args = ""; switch (changesAction) { case LocalChangesAction.Merge: args = " --merge"; break; case LocalChangesAction.Reset: args = " --force"; break; } return(string.Format("checkout{0} \"{1}\"", args, branchOrRevisionName)); }
public static string CheckoutCmd(string branchOrRevisionName, LocalChangesAction changesAction) { string args = ""; switch (changesAction) { case LocalChangesAction.Merge: args = " --merge"; break; case LocalChangesAction.Reset: args = " --force"; break; } return string.Format("checkout{0} \"{1}\"", args, branchOrRevisionName); }
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.StashSave(owner, AppSettings.IncludeUntrackedFilesInAutoStash); } } 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) { UICommands.StashPop(this); } } UICommands.UpdateSubmodules(this); return(DialogResult.OK); } return(DialogResult.None); }
private DialogResult OkClick() { // Ok button set as the "AcceptButton" for the form // if the user hits [Enter] at any point, we need to trigger txtCustomBranchName Leave event Ok.Focus(); 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) { IGitRef localBranchRef = GetLocalBranchRef(_localBranchName); IGitRef remoteBranchRef = GetRemoteBranchRef(cmd.BranchName); if (localBranchRef != null && remoteBranchRef != null) { string mergeBaseGuid = Module.GetMergeBase(localBranchRef.Guid, remoteBranchRef.Guid); bool isResetFastForward = localBranchRef.Guid.Equals(mergeBaseGuid); if (!isResetFastForward) { string mergeBaseText = mergeBaseGuid.IsNullOrWhiteSpace() ? "merge base" : GitRevision.ToShortSha(mergeBaseGuid); string warningMessage = string.Format(_resetNonFastForwardBranch.Text, _localBranchName, mergeBaseText); if (MessageBox.Show(this, warningMessage, _resetCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { DialogResult = DialogResult.None; return(DialogResult.None); } } } cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.Reset; cmd.NewBranchName = _localBranchName; } else { cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.DontCreate; cmd.NewBranchName = null; } } LocalChangesAction changes = ChangesMode; if (changes != LocalChangesAction.Reset && chkSetLocalChangesActionAsDefault.Checked) { AppSettings.CheckoutBranchAction = changes; } if ((Visible || AppSettings.UseDefaultCheckoutBranchAction) && HasUncommittedChanges) { 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.StashSave(owner, AppSettings.IncludeUntrackedFilesInAutoStash); } } var originalHash = Module.GetCurrentCheckout(); ScriptManager.RunEventScripts(this, ScriptEvent.BeforeCheckout); if (UICommands.StartCommandLineProcessDialog(cmd, owner)) { if (stash) { bool?messageBoxResult = AppSettings.AutoPopStashAfterCheckoutBranch; if (messageBoxResult == null) { DialogResult res = cTaskDialog.MessageBox( this, _applyShashedItemsAgainCaption.Text, "", _applyShashedItemsAgain.Text, "", "", _dontShowAgain.Text, eTaskDialogButtons.YesNo, eSysIcons.Question, eSysIcons.Question); messageBoxResult = res == DialogResult.Yes; if (cTaskDialog.VerificationChecked) { AppSettings.AutoPopStashAfterCheckoutBranch = messageBoxResult; } } if (messageBoxResult ?? false) { UICommands.StashPop(this); } } var currentHash = Module.GetCurrentCheckout(); if (!string.Equals(originalHash, currentHash, StringComparison.OrdinalIgnoreCase)) { UICommands.UpdateSubmodules(this); } ScriptManager.RunEventScripts(this, ScriptEvent.AfterCheckout); return(DialogResult.OK); } return(DialogResult.None); }
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; Settings.CheckoutBranchAction = changes; if (IsThereUncommittedChanges() && (Visible || Settings.UseDefaultCheckoutBranchAction)) { cmd.LocalChanges = changes; } else { cmd.LocalChanges = LocalChangesAction.DontChange; } IWin32Window owner = Visible ? this : Owner; bool stash = changes == LocalChangesAction.Stash && (_isDirtyDir ?? Module.IsDirtyDir()); if (stash) { UICommands.Stash(owner); } if (UICommands.StartCommandLineProcessDialog(cmd, owner)) { if (stash) { bool?messageBoxResult = Settings.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) { Settings.AutoPopStashAfterCheckoutBranch = messageBoxResult; } } if (messageBoxResult ?? false) { FormProcess.ShowDialog(this, Module, "stash pop"); MergeConflictHandler.HandleMergeConflicts(UICommands, this, false); } } return(DialogResult.OK); } return(DialogResult.None); }
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; Settings.CheckoutBranchAction = changes; if (ShowLocalChangesGB()) { cmd.LocalChanges = changes; } else { cmd.LocalChanges = LocalChangesAction.DontChange; } IWin32Window _owner = Visible ? this : Owner; //Stash local changes, but only if the setting CheckForUncommittedChangesInCheckoutBranch is true if (Settings.CheckForUncommittedChangesInCheckoutBranch && changes == LocalChangesAction.Stash && Module.IsDirtyDir()) { UICommands.Stash(_owner); } { var successfullyCheckedOut = UICommands.StartCommandLineProcessDialog(cmd, _owner); if (successfullyCheckedOut) { return(DialogResult.OK); } else { return(DialogResult.None); } } }