public static bool ShowDialog(IWin32Window owner, string process, string arguments, string aWorkingDirectory, string input, bool useDialogSettings) { using (var formProcess = new FormProcess(process, arguments, aWorkingDirectory, input, useDialogSettings)) { formProcess.ShowDialog(owner); return !formProcess.ErrorOccurred(); } }
private void OkClick(object sender, EventArgs e) { var process = new FormProcess(GitCommandHelpers.MergeBranchCmd(Branches.Text, fastForward.Checked, squash.Checked, noCommit.Checked, _NO_TRANSLATE_mergeStrategy.Text)); process.ShowDialog(); var wasConflict = MergeConflictHandler.HandleMergeConflicts(); if (!process.ErrorOccurred() || wasConflict) Close(); }
private void BisectRange( string startRevision, string endRevision ) { var command = GitCommandHelpers.MarkRevisionBisectCmd(true, startRevision); var form = new FormProcess(command); form.ShowDialog(this); if (!form.ErrorOccurred()) { command = GitCommandHelpers.MarkRevisionBisectCmd(false, endRevision); form = new FormProcess(command); form.ShowDialog(this); } }
private void BisectRange(string startRevision, string endRevision) { var command = GitCommandHelpers.ContinueBisectCmd(GitBisectOption.Good, startRevision); using (var form = new FormProcess(command)) { form.ShowDialog(this); if (form.ErrorOccurred()) return; } command = GitCommandHelpers.ContinueBisectCmd(GitBisectOption.Bad, endRevision); FormProcess.ShowDialog(this, command); }
private void OkClick(object sender, EventArgs e) { try { var command = "checkout"; if (Remotebranch.Checked) { //Get a localbranch name var remoteName = GitCommandHelpers.GetRemoteName(Branches.Text, GitCommandHelpers.GetRemotes()); var localBranchName = Branches.Text.Substring(remoteName.Length + 1); MessageBoxIcon icon = MessageBoxIcon.Question; //try to determine the 'best' name for a local branch, check if the local //name for the remote branch is already used if (LocalBranchExists(localBranchName)) { localBranchName = string.Concat(remoteName, "_", localBranchName); icon = MessageBoxIcon.Exclamation; } var result = MessageBox.Show(string.Format(trackRemoteBranch.Text, localBranchName), trackRemoteBranchCaption.Text, MessageBoxButtons.YesNoCancel, icon); if (result == DialogResult.Cancel) { return; } if (result == DialogResult.Yes) { command += string.Format(" -b {0}", localBranchName); } } if (Force.Checked) { command += " --force"; } command += " \"" + Branches.Text + "\""; var form = new FormProcess(command); form.ShowDialog(); if (!form.ErrorOccurred()) { Close(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private void okButton_Click(object sender, EventArgs e) { try { var dirTo = this._NO_TRANSLATE_destinationComboBox.Text; if (!dirTo.EndsWith(Settings.PathSeparator.ToString()) && !dirTo.EndsWith(Settings.PathSeparatorWrong.ToString())) { dirTo += Settings.PathSeparator.ToString(); } dirTo += this._NO_TRANSLATE_subdirectoryTextBox.Text; //Repositories.RepositoryHistory.AddMostRecentRepository(_NO_TRANSLATE_From.Text); //Repositories.RepositoryHistory.AddMostRecentRepository(dirTo); if (!Directory.Exists(dirTo)) { Directory.CreateDirectory(dirTo); } var authorsfile = this._NO_TRANSLATE_authorsFileTextBox.Text; bool resetauthorsfile = false; if (authorsfile != null && authorsfile.Trim().Length != 0 && !File.Exists(authorsfile.Trim()) && !(resetauthorsfile = this.AskContinutWithoutAuthorsFile(authorsfile))) { return; } if (resetauthorsfile) { authorsfile = null; } var fromProcess = new FormProcess( Settings.GitCommand, GitSvnCommandHelpers.CloneCmd(this._NO_TRANSLATE_svnRepositoryComboBox.Text, dirTo, authorsfile)); fromProcess.ShowDialog(this); if (fromProcess.ErrorOccurred() || Settings.Module.InTheMiddleOfPatch()) { return; } if (ShowInTaskbar == false && AskIfNewRepositoryShouldBeOpened(dirTo)) { Settings.WorkingDir = dirTo; } Close(); } catch (Exception ex) { MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OkClick(object sender, EventArgs e) { Settings.NoFastForwardMerge = noFastForward.Checked; var process = new FormProcess(GitCommandHelpers.MergeBranchCmd(Branches.GetSelectedText(), fastForward.Checked, squash.Checked, noCommit.Checked, _NO_TRANSLATE_mergeStrategy.Text)); process.ShowDialog(this); var wasConflict = MergeConflictHandler.HandleMergeConflicts(this); if (!process.ErrorOccurred() || wasConflict) { Close(); } }
private void OkClick(object sender, EventArgs e) { try { var dirTo = _NO_TRANSLATE_To.Text; if (!dirTo.EndsWith(Settings.PathSeparator.ToString()) && !dirTo.EndsWith(Settings.PathSeparatorWrong.ToString())) { dirTo += Settings.PathSeparator.ToString(); } dirTo += _NO_TRANSLATE_NewDirectory.Text; Repositories.RepositoryHistory.AddMostRecentRepository(_NO_TRANSLATE_From.Text); Repositories.RepositoryHistory.AddMostRecentRepository(dirTo); var fromProcess = new FormProcess(Settings.GitCommand, GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo, CentralRepository.Checked, Branches.Text, null)); fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text); fromProcess.ShowDialog(); if (fromProcess.ErrorOccurred() || GitCommandHelpers.InTheMiddleOfPatch()) { return; } if (ShowInTaskbar == false && AskIfNewRepositoryShouldBeOpened(dirTo)) { Settings.WorkingDir = dirTo; if (File.Exists(Settings.WorkingDir + ".gitmodules") && AskIfSubmodulesShouldBeInitialized()) { InitSubmodules(); } } Close(); } catch (Exception ex) { MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OkClick(object sender, EventArgs e) { try { Settings.MergeAtCheckout = rbMerge.Checked; Settings.CreateLocalBranchForRemote = rbCreateBranch.Checked; var command = "checkout"; //Get a localbranch name if (rbCreateBranch.Checked) { command += string.Format(" -b {0}", _newLocalBranchName); } else if (rbResetBranch.Checked) { command += string.Format(" -B {0}", _localBranchName); } if (rbMerge.Checked) { command += " -m"; } if (rbReset.Checked) { command += " --force"; } command += " \"" + _branch + "\""; var form = new FormProcess(command); form.ShowDialog(this); if (!form.ErrorOccurred()) { Close(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private bool EvaluateResultsBasedOnSettings(bool stashed, FormProcess process) { if (!Settings.Module.InTheMiddleOfConflictedMerge() && !Settings.Module.InTheMiddleOfRebase() && (process != null && !process.ErrorOccurred())) { InitModules(); return(true); } // Rebase failed -> special 'rebase' merge conflict if (Rebase.Checked && Settings.Module.InTheMiddleOfRebase()) { GitUICommands.Instance.StartRebaseDialog(null); if (!Settings.Module.InTheMiddleOfConflictedMerge() && !Settings.Module.InTheMiddleOfRebase()) { return(true); } } else { MergeConflictHandler.HandleMergeConflicts(this); if (!Settings.Module.InTheMiddleOfConflictedMerge() && !Settings.Module.InTheMiddleOfRebase()) { return(true); } } if (!AutoStash.Checked || !stashed || Settings.Module.InTheMiddleOfConflictedMerge() || Settings.Module.InTheMiddleOfRebase()) { return(true); } return(false); }
private void OkClick(object sender, EventArgs e) { try { var dirTo = _NO_TRANSLATE_To.Text; if (!dirTo.EndsWith(Settings.PathSeparator.ToString()) && !dirTo.EndsWith(Settings.PathSeparatorWrong.ToString())) dirTo += Settings.PathSeparator.ToString(); dirTo += _NO_TRANSLATE_NewDirectory.Text; Repositories.RepositoryHistory.AddMostRecentRepository(_NO_TRANSLATE_From.Text); Repositories.RepositoryHistory.AddMostRecentRepository(dirTo); var fromProcess = new FormProcess(Settings.GitCommand, GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo, CentralRepository.Checked, null)); fromProcess.ShowDialog(); if (fromProcess.ErrorOccurred() || GitCommandHelpers.InTheMiddleOfPatch()) return; if (ShowInTaskbar == false && AskIfNewRepositoryShouldBeOpened(dirTo)) { Settings.WorkingDir = dirTo; if (File.Exists(Settings.WorkingDir + ".gitmodules") && AskIfSubmodulesShouldBeInitialized()) InitSubmodules(); } Close(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private void OkClick(object sender, EventArgs e) { try { Settings.AutoStash = cbAutoStash.Checked; var command = "checkout"; //Get a localbranch name if (rbCreateBranch.Checked) command += string.Format(" -b {0}", _newLocalBranchName); else if (rbResetBranch.Checked) command += string.Format(" -B {0}", _localBranchName); command += " \"" + _branch + "\""; bool stashed = CalculateStashedValue(); var form = new FormProcess(command); form.ShowDialog(this); if (!form.ErrorOccurred() && stashed) { bool messageBoxResult = MessageBox.Show(this, _applyShashedItemsAgain.Text, _applyShashedItemsAgainCaption.Text, MessageBoxButtons.YesNo) == DialogResult.Yes; if (messageBoxResult) new FormProcess("stash pop").ShowDialog(this); } if (!form.ErrorOccurred()) Close(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private void PushClick(object sender, EventArgs e) { if (PullFromUrl.Checked && string.IsNullOrEmpty(PushDestination.Text)) { MessageBox.Show(_selectDestinationDirectory.Text); return; } if (PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text)) { MessageBox.Show(_selectRemote.Text); return; } if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(TagComboBox.Text) && !PushAllTags.Checked) { MessageBox.Show(_selectTag.Text); return; } bool newBranch = false; //Extra check if the branch is already known to the remote, give a warning when not. //This is not possible when the remote is an URL, but this is ok since most users push to //known remotes anyway. if (TabControlTagBranch.SelectedTab == BranchTab && PullFromRemote.Checked) { //The current branch is not known by the remote (as far as we now since we are disconnected....) if (!GitCommandHelpers.GetHeads(true, true).Exists(x => x.Remote == Remotes.Text && x.LocalName == RemoteBranch.Text)) { //Ask if this is what the user wants if (MessageBox.Show(_branchNewForRemote.Text, _pushCaption.Text, MessageBoxButtons.YesNo) == DialogResult.No) { return; } else { newBranch = true; } } } Repositories.RepositoryHistory.AddMostRecentRepository(PushDestination.Text); Settings.PushAllTags = PushAllTags.Checked; var remote = ""; string destination; if (PullFromUrl.Checked) { destination = PushDestination.Text; } else { if (GitCommandHelpers.Plink()) { if (!File.Exists(Settings.Pageant)) { MessageBox.Show(_cannotLoadPutty.Text, PuttyText); } else { GitCommandHelpers.StartPageantForRemote(Remotes.Text); } } destination = Remotes.Text; remote = Remotes.Text.Trim(); } string pushCmd; if (TabControlTagBranch.SelectedTab == BranchTab) { pushCmd = GitCommandHelpers.PushCmd(destination, Branch.Text, RemoteBranch.Text, PushAllBranches.Checked, ForcePushBranches.Checked, newBranch); } else if (TabControlTagBranch.SelectedTab == TagTab) { pushCmd = GitCommandHelpers.PushTagCmd(destination, TagComboBox.Text, PushAllTags.Checked, ForcePushBranches.Checked); } else { var pushActions = new List <GitPushAction>(); foreach (DataRow row in _branchTable.Rows) { var push = (bool)row["Push"]; var force = (bool)row["Force"]; var delete = (bool)row["Delete"]; if (push || force) { pushActions.Add(new GitPushAction(row["Local"].ToString(), row["Remote"].ToString(), force)); } else if (delete) { pushActions.Add(new GitPushAction(row["Remote"].ToString())); } } pushCmd = GitCommandHelpers.PushMultipleCmd(destination, pushActions); } var form = new FormProcess(pushCmd) { Remote = remote, Text = string.Format(_pushToCaption.Text, destination) }; form.ShowDialog(); if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() && !GitCommandHelpers.InTheMiddleOfRebase() && !form.ErrorOccurred()) { Close(); if (_createPullRequestCB.Checked) { GitUICommands.Instance.StartCreatePullRequest(); } } }
private void ShowProcessDialogBox(string source, FormProcess process) { if (process == null) return; if (!PullAll()) process.Remote = source; process.ShowDialog(this); ErrorOccurred = process.ErrorOccurred(); }
private void PushClick(object sender, EventArgs e) { GitCommands.Settings.WaitUntilAllSettingsLoaded(); if (PullFromUrl.Checked && string.IsNullOrEmpty(PushDestination.Text)) { MessageBox.Show(_selectDestinationDirectory.Text); return; } if (PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text)) { MessageBox.Show(_selectRemote.Text); return; } if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(TagComboBox.Text) && !PushAllTags.Checked) { MessageBox.Show(_selectTag.Text); return; } //Extra check if the branch is already known to the remote, give a warning when not. //This is not possible when the remote is an URL, but this is ok since most users push to //known remotes anyway. if (TabControlTagBranch.SelectedTab == BranchTab && PullFromRemote.Checked) { //The current branch is not known by the remote (as far as we now since we are disconnected....) if (!GitCommandHelpers.GetHeads(true, true).Exists(x => x.Remote == Remotes.Text && x.LocalName == RemoteBranch.Text)) //Ask if this is what the user wants if (MessageBox.Show(_branchNewForRemote.Text, _pushCaption.Text, MessageBoxButtons.YesNo) == DialogResult.No) return; } Repositories.RepositoryHistory.AddMostRecentRepository(PushDestination.Text); var remote = ""; string destination; if (PullFromUrl.Checked) { destination = PushDestination.Text; } else { if (GitCommandHelpers.Plink()) { if (!File.Exists(Settings.Pageant)) MessageBox.Show(_cannotLoadPutty.Text, PuttyText); else GitCommandHelpers.StartPageantForRemote(Remotes.Text); } destination = Remotes.Text; remote = Remotes.Text.Trim(); } string pushCmd; if (TabControlTagBranch.SelectedTab == BranchTab) pushCmd = GitCommands.GitCommandHelpers.PushCmd(destination, Branch.Text, RemoteBranch.Text, PushAllBranches.Checked, ForcePushBranches.Checked); else pushCmd = GitCommands.GitCommandHelpers.PushTagCmd(destination, TagComboBox.Text, PushAllTags.Checked, ForcePushBranches.Checked); var form = new FormProcess(pushCmd) { Remote = remote, Text = string.Format(_pushToCaption.Text, destination) }; form.ShowDialog(); if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() && !GitCommandHelpers.InTheMiddleOfRebase() && !form.ErrorOccurred()) Close(); }
private void DoCommit(bool amend, bool push) { if (GitCommandHelpers.InTheMiddleOfConflictedMerge()) { MessageBox.Show(_mergeConflicts.Text, _mergeConflictsCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(Message.Text)) { MessageBox.Show(_enterCommitMessage.Text, _enterCommitMessageCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (GitCommandHelpers.GetSelectedBranch().Equals("(no branch)", StringComparison.OrdinalIgnoreCase) && MessageBox.Show(_notOnBranch.Text, _notOnBranchCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { return; } try { SetCommitMessageFromTextBox(Message.Text); ScriptManager.RunEventScripts(ScriptEvent.BeforeCommit); var form = new FormProcess(GitCommandHelpers.CommitCmd(amend, toolAuthor.Text)); form.ShowDialog(); NeedRefresh = true; if (form.ErrorOccurred()) { return; } ScriptManager.RunEventScripts(ScriptEvent.AfterCommit); Message.Text = string.Empty; if (push) { GitUICommands.Instance.StartPushDialog(true); } if (Settings.CloseCommitDialogAfterCommit) { Close(); return; } if (Unstaged.GitItemStatuses.Any(gitItemStatus => gitItemStatus.IsTracked)) { InitializedStaged(); return; } if (Settings.CloseCommitDialogAfterLastCommit) { Close(); } else { InitializedStaged(); } } catch (Exception e) { MessageBox.Show(string.Format("Exception: {0}", e.Message)); } }
private void OkClick(object sender, EventArgs e) { try { Settings.MergeAtCheckout = cbMerge.Checked; var command = "checkout"; //Get a localbranch name if (rbCreateBranch.Checked) command += string.Format(" -b {0}", _newLocalBranchName); else if (rbResetBranch.Checked) command += string.Format(" -B {0}", _localBranchName); if (cbMerge.Checked) command += " -m"; command += " \"" + _branch + "\""; var form = new FormProcess(command); form.ShowDialog(this); if (!form.ErrorOccurred()) Close(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private void ShowProcessDialogBox(IWin32Window owner, string source, FormProcess process) { if (process == null) return; if (!IsPullAll()) process.Remote = source; process.ShowDialog(owner); ErrorOccurred = process.ErrorOccurred(); }
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; }
private void okButton_Click(object sender, EventArgs e) { try { var dirTo = this._NO_TRANSLATE_destinationComboBox.Text; if (!dirTo.EndsWith(Settings.PathSeparator.ToString()) && !dirTo.EndsWith(Settings.PathSeparatorWrong.ToString())) dirTo += Settings.PathSeparator.ToString(); dirTo += this._NO_TRANSLATE_subdirectoryTextBox.Text; //Repositories.RepositoryHistory.AddMostRecentRepository(_NO_TRANSLATE_From.Text); //Repositories.RepositoryHistory.AddMostRecentRepository(dirTo); if (!Directory.Exists(dirTo)) Directory.CreateDirectory(dirTo); var authorsfile = this._NO_TRANSLATE_authorsFileTextBox.Text; bool resetauthorsfile = false; if (authorsfile != null && authorsfile.Trim().Length != 0 && !File.Exists(authorsfile.Trim()) && !(resetauthorsfile = this.AskContinutWithoutAuthorsFile(authorsfile))) { return; } if (resetauthorsfile) { authorsfile = null; } var fromProcess = new FormProcess( Settings.GitCommand, GitSvnCommandHelpers.CloneCmd(this._NO_TRANSLATE_svnRepositoryComboBox.Text, dirTo, authorsfile)); fromProcess.ShowDialog(this); if (fromProcess.ErrorOccurred() || Settings.Module.InTheMiddleOfPatch()) return; if (ShowInTaskbar == false && AskIfNewRepositoryShouldBeOpened(dirTo)) { Settings.WorkingDir = dirTo; } Close(); } catch (Exception ex) { MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DoCommit(bool amend, bool push) { if (Settings.Module.InTheMiddleOfConflictedMerge()) { MessageBox.Show(this, _mergeConflicts.Text, _mergeConflictsCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(Message.Text) || Message.Text == commitTemplate) { MessageBox.Show(this, _enterCommitMessage.Text, _enterCommitMessageCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (!ValidCommitMessage()) return; if (Settings.Module.GetSelectedBranch().Equals("(no branch)", StringComparison.OrdinalIgnoreCase)) { int idx = PSTaskDialog.cTaskDialog.ShowCommandBox(this, _notOnBranchCaption.Text, _notOnBranchMainInstruction.Text, _notOnBranch.Text, _notOnBranchButtons.Text, true); switch (idx) { case 0: string revision = _editedCommit != null ? _editedCommit.Guid : ""; if (!GitUICommands.Instance.StartCheckoutBranchDialog(revision)) return; break; case -1: return; } } try { SetCommitMessageFromTextBox(Message.Text); ScriptManager.RunEventScripts(ScriptEvent.BeforeCommit); var form = new FormProcess(Settings.Module.CommitCmd(amend, signOffToolStripMenuItem.Checked, toolAuthor.Text)); form.ShowDialog(this); NeedRefresh = true; if (form.ErrorOccurred()) return; ScriptManager.RunEventScripts(ScriptEvent.AfterCommit); Message.Text = string.Empty; GitCommands.Commit.SetCommitMessage(string.Empty); if (push) { GitUICommands.Instance.StartPushDialog(this, true); } if (Settings.CloseCommitDialogAfterCommit) { Close(); return; } if (Unstaged.GitItemStatuses.Any(gitItemStatus => gitItemStatus.IsTracked)) { InitializedStaged(); return; } if (Settings.CloseCommitDialogAfterLastCommit) Close(); else InitializedStaged(); } catch (Exception e) { MessageBox.Show(this, string.Format("Exception: {0}", e.Message)); } }
private void OkClick(object sender, EventArgs e) { try { var command = "checkout"; if (Remotebranch.Checked) { //Get a localbranch name var remoteName = GitCommandHelpers.GetRemoteName(Branches.Text, GitCommandHelpers.GetRemotes()); var localBranchName = Branches.Text.Substring(remoteName.Length + 1); //try to determine the 'best' name for a local branch, check if the local //name for the remote branch is already used if (LocalBranchExists(localBranchName)) localBranchName = string.Concat(remoteName, "_", localBranchName); var result = MessageBox.Show(string.Format(trackRemoteBranch.Text, localBranchName), trackRemoteBranchCaption.Text, MessageBoxButtons.YesNoCancel); if (result == DialogResult.Cancel) return; if (result == DialogResult.Yes) command += string.Format(" -b {0}", localBranchName); } if (Force.Checked) command += " --force"; command += " \"" + Branches.Text + "\""; var form = new FormProcess(command); form.ShowDialog(); if (!form.ErrorOccurred()) Close(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private void DoCommit(bool amend, bool push) { if (GitCommandHelpers.InTheMiddleOfConflictedMerge()) { MessageBox.Show(_mergeConflicts.Text, _mergeConflictsCaption.Text); return; } if (Message.Text.Length < 3) { MessageBox.Show(_enterCommitMessage.Text, _enterCommitMessageCaption.Text); return; } if (GitCommandHelpers.GetSelectedBranch().Equals("(no branch)", StringComparison.OrdinalIgnoreCase) && MessageBox.Show(_notOnBranch.Text, _notOnBranchCaption.Text, MessageBoxButtons.YesNo) == DialogResult.No) return; try { SetCommitMessageFromTextBox(Message.Text); var form = new FormProcess(GitCommandHelpers.CommitCmd(amend)); form.ShowDialog(); NeedRefresh = true; if (form.ErrorOccurred()) return; Message.Text = string.Empty; if (push) { GitUICommands.Instance.StartPushDialog(true); } if (CloseDialogAfterCommit.Checked) { Close(); return; } foreach (var gitItemStatus in Unstaged.GitItemStatuses) { if (gitItemStatus.IsTracked) { InitializedStaged(); return; } } Close(); } catch (Exception e) { MessageBox.Show(string.Format("Exception: {0}", e.Message)); } }
private bool ShouldStashPop(bool messageBoxResult, FormProcess process, bool stashed) { return stashed && process != null && !process.ErrorOccurred() && !Module.InTheMiddleOfConflictedMerge() && !Module.InTheMiddleOfRebase() && messageBoxResult; }
private bool PushChanges() { if (PullFromUrl.Checked && string.IsNullOrEmpty(PushDestination.Text)) { MessageBox.Show(_selectDestinationDirectory.Text); return false; } if (PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text)) { MessageBox.Show(_selectRemote.Text); return false; } if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(TagComboBox.Text) && !PushAllTags.Checked) { MessageBox.Show(_selectTag.Text); return false; } bool newBranch = false; //Extra check if the branch is already known to the remote, give a warning when not. //This is not possible when the remote is an URL, but this is ok since most users push to //known remotes anyway. if (TabControlTagBranch.SelectedTab == BranchTab && PullFromRemote.Checked) { //The current branch is not known by the remote (as far as we now since we are disconnected....) if (!GitCommandHelpers.GetHeads(true, true).Exists(x => x.Remote == Remotes.Text && x.LocalName == RemoteBranch.Text)) //Ask if this is what the user wants if (MessageBox.Show(_branchNewForRemote.Text, _pushCaption.Text, MessageBoxButtons.YesNo) == DialogResult.No) { return false; } else { newBranch = true; } } Repositories.RepositoryHistory.AddMostRecentRepository(PushDestination.Text); Settings.PushAllTags = PushAllTags.Checked; var remote = ""; string destination; if (PullFromUrl.Checked) { destination = PushDestination.Text; } else { if (GitCommandHelpers.Plink()) { if (!File.Exists(Settings.Pageant)) MessageBox.Show(_cannotLoadPutty.Text, PuttyText); else GitCommandHelpers.StartPageantForRemote(Remotes.Text); } destination = Remotes.Text; remote = Remotes.Text.Trim(); } string pushCmd; if (TabControlTagBranch.SelectedTab == BranchTab) { bool track = newBranch; string[] remotes = Remotes.DataSource as string[]; if (remotes != null) foreach (string remoteBranch in remotes) if (!string.IsNullOrEmpty(remoteBranch) && Branch.Text.StartsWith(remoteBranch)) track = false; pushCmd = GitCommandHelpers.PushCmd(destination, Branch.Text, RemoteBranch.Text, PushAllBranches.Checked, ForcePushBranches.Checked, track); } else if (TabControlTagBranch.SelectedTab == TagTab) pushCmd = GitCommandHelpers.PushTagCmd(destination, TagComboBox.Text, PushAllTags.Checked, ForcePushBranches.Checked); else { var pushActions = new List<GitPushAction>(); foreach (DataRow row in _branchTable.Rows) { var push = (bool)row["Push"]; var force = (bool)row["Force"]; var delete = (bool)row["Delete"]; if (push || force) pushActions.Add(new GitPushAction(row["Local"].ToString(), row["Remote"].ToString(), force)); else if (delete) pushActions.Add(new GitPushAction(row["Remote"].ToString())); } pushCmd = GitCommandHelpers.PushMultipleCmd(destination, pushActions); } ScriptManager.RunEventScripts(ScriptEvent.BeforePush); var form = new FormProcess(pushCmd) { Remote = remote, Text = string.Format(_pushToCaption.Text, destination) }; form.ShowDialog(); if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() && !GitCommandHelpers.InTheMiddleOfRebase() && !form.ErrorOccurred()) { ScriptManager.RunEventScripts(ScriptEvent.AfterPush); if (_createPullRequestCB.Checked) GitUICommands.Instance.StartCreatePullRequest(); return true; } return false; }
private void DoCommit(bool amend, bool push) { if (GitCommandHelpers.InTheMiddleOfConflictedMerge()) { MessageBox.Show(_mergeConflicts.Text, _mergeConflictsCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(Message.Text)) { MessageBox.Show(_enterCommitMessage.Text, _enterCommitMessageCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (GitCommandHelpers.GetSelectedBranch().Equals("(no branch)", StringComparison.OrdinalIgnoreCase) && MessageBox.Show(_notOnBranch.Text, _notOnBranchCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) return; try { SetCommitMessageFromTextBox(Message.Text); var form = new FormProcess(GitCommandHelpers.CommitCmd(amend, toolAuthor.Text)); form.ShowDialog(); NeedRefresh = true; if (form.ErrorOccurred()) return; Message.Text = string.Empty; if (push) { GitUICommands.Instance.StartPushDialog(true); } if (Settings.CloseCommitDialogAfterCommit) { Close(); return; } if (Unstaged.GitItemStatuses.Any(gitItemStatus => gitItemStatus.IsTracked)) { InitializedStaged(); return; } if (Settings.CloseCommitDialogAfterLastCommit) Close(); else InitializedStaged(); } catch (Exception e) { MessageBox.Show(string.Format("Exception: {0}", e.Message)); } }
private void OkClick(object sender, EventArgs e) { if (Remotebranch.Checked) { var checkoutRemote = new FormCheckoutRemoteBranch(Branches.Text, Force.Checked); checkoutRemote.ShowDialog(this); } else { try { var command = "checkout"; if (Force.Checked) command += " --force"; command += " \"" + Branches.Text + "\""; var form = new FormProcess(command); form.ShowDialog(this); if (!form.ErrorOccurred()) Close(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } } }