public void SetLocalChangesFromSettings(Settings.LocalChanges changes) { if (changes == Settings.LocalChanges.Merge) { LocalChangesAction = LocalChanges.Merge; } else if (changes == Settings.LocalChanges.Reset) { LocalChangesAction = LocalChanges.Reset; } else { LocalChangesAction = LocalChanges.DontChange; } }
public static string CheckoutCmd(string branchOrRevisionName, Settings.LocalChanges changes) { string args = ""; switch (changes) { case Settings.LocalChanges.Merge: args = " --merge"; break; case Settings.LocalChanges.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; } } Settings.LocalChanges changes = ChangesMode; Settings.CheckoutBranchAction = changes; Settings.UseDefaultCheckoutBranchAction = defaultActionChx.Checked; if (ShowLocalChangesGB()) { cmd.SetLocalChangesFromSettings(changes); } else { cmd.SetLocalChangesFromSettings(Settings.LocalChanges.DontChange); } IWin32Window _owner = Visible ? this : Owner; //Stash local changes, but only if the setting CheckForUncommittedChangesInCheckoutBranch is true if (Settings.CheckForUncommittedChangesInCheckoutBranch && changes == Settings.LocalChanges.Stash && Module.IsDirtyDir()) { UICommands.Stash(_owner); } { var successfullyCheckedOut = UICommands.StartCommandLineProcessDialog(cmd, _owner); if (successfullyCheckedOut) { return(DialogResult.OK); } else { return(DialogResult.None); } } }
private void Initialize() { Text = String.Format(Text, _branch); _remoteName = GitModule.GetRemoteName(_branch, GitModule.Current.GetRemotes(false)); _localBranchName = _branch.Substring(_remoteName.Length + 1); _newLocalBranchName = string.Concat(_remoteName, "_", _localBranchName); int i = 2; while (LocalBranchExists(_newLocalBranchName)) { _newLocalBranchName = string.Concat(_remoteName, "_", _localBranchName, "_", i.ToString()); i++; } bool existsLocalBranch = LocalBranchExists(_localBranchName); rbCreateBranch.Checked = Settings.CreateLocalBranchForRemote; rbResetBranch.Text = String.Format(existsLocalBranch ? rbResetBranch.Text : rbCreateBranch.Text, _localBranchName); rbCreateBranch.Text = String.Format(rbCreateBranch.Text, _newLocalBranchName); txtCustomBranchName.Text = _localBranchName; ChangesMode = Settings.CheckoutBranchAction; }