private void SynchronizeSubmoduleClick(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; var process = new FormProcess(GitCommands.GitCommands.SubmoduleSyncCmd(SubModuleName.Text)); process.ShowDialog(); Initialize(); }
private void OkClick(object sender, EventArgs e) { try { //Get a localbranch name var remoteName = GitCommands.GitCommands.GetRemoteName(Branches.Text, GitCommands.GitCommands.GetRemotes()); var localBranchName = Branches.Text.Substring(remoteName.Length + 1); var command = "checkout"; if (Remotebranch.Checked) { var result = MessageBox.Show( "You choose to checkout a remote branch." + Environment.NewLine + Environment.NewLine + "Do you want create a local branch with the name '" + localBranchName + "'" + Environment.NewLine + "that track's this remote branch?", "Checkout branch", MessageBoxButtons.YesNo); 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.ErrorOccured()) Close(); } catch(Exception ex) { Trace.WriteLine(ex.Message); } }
private void InitSubmodule_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; FormProcess process = new FormProcess(GitCommands.GitCommands.SubmoduleInitCmd(SubModuleName.Text)); process.ShowDialog(); Initialize(); }
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 Ok_Click(object sender, EventArgs e) { FormProcess process = new FormProcess(GitCommands.GitCommands.MergeBranchCmd(Branches.Text, !NoFastForward.Checked)); MergeConflictHandler.HandleMergeConflicts(); if (!process.ErrorOccured()) Close(); }
private void Cleanup_Click(object sender, EventArgs e) { if (MessageBox.Show(_reallyCleanupQuestion.Text, _reallyCleanupQuestionCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var form = new FormProcess(GitCommandHelpers.CleanUpCmd(false, RemoveDirectories.Checked, RemoveNonIgnored.Checked, RemoveIngnored.Checked)); form.ShowDialog(); PreviewOutput.Text = form.OutputString.ToString(); } }
private void Cleanup_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to cleanup the repository?", "Cleanup", MessageBoxButtons.YesNo) == DialogResult.Yes) { FormProcess form = new FormProcess(GitCommandHelpers.CleanUpCmd(false, RemoveDirectories.Checked, RemoveNonIgnored.Checked, RemoveIngnored.Checked)); form.ShowDialog(); PreviewOutput.Text = form.OutputString.ToString(); } }
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) return; command = GitCommandHelpers.MarkRevisionBisectCmd(false, endRevision); form = new FormProcess(command); form.ShowDialog(this); }
private void Add_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(Directory.Text) || string.IsNullOrEmpty(LocalPath.Text)) { MessageBox.Show("A remote path and local path are required"); return; } Cursor.Current = Cursors.WaitCursor; FormProcess formProcess = new FormProcess(GitCommands.GitCommands.AddSubmoduleCmd(Directory.Text, LocalPath.Text, Branch.Text)); Close(); }
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 button1_Click(object sender, EventArgs e) { string options = ""; if (Unreachable.Checked) options += " --unreachable"; if (FullCheck.Checked) options += " --full"; if (NoReflogs.Checked) options += " --no-reflogs"; FormProcess process = new FormProcess("fsck-objects --lost-found" + options); FormVerify_Shown(null, null); }
private static void InitializeSubmodulesRecursive() { string oldworkingdir = Settings.WorkingDir; foreach (GitSubmodule submodule in GitCommands.GitCommands.GetSubmodules()) { Settings.WorkingDir = oldworkingdir + submodule.LocalPath; if (File.Exists(GitCommands.Settings.WorkingDir + ".gitmodules")) { FormProcess process = new FormProcess(GitCommands.GitCommands.SubmoduleInitCmd("")); InitializeSubmodulesRecursive(); } } Settings.WorkingDir = oldworkingdir; }
private void OkClick(object sender, EventArgs e) { try { if (Revision == null) { MessageBox.Show(_noRevisionSelected.Text, Text); return; } var branchCmd = GitCommandHelpers.BranchCmd(BranchNameTextBox.Text, Revision.Guid, CheckoutAfterCreate.Checked); using (var formProcess = new FormProcess(branchCmd)) { formProcess.ShowDialog(); } DialogResult = DialogResult.OK; } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private static void InitializeSubmodulesRecursive() { string oldworkingdir = Settings.WorkingDir; foreach (GitSubmodule submodule in (new GitCommands.GitCommands()).GetSubmodules()) { if (!string.IsNullOrEmpty(submodule.LocalPath)) { Settings.WorkingDir = oldworkingdir + submodule.LocalPath; if (Settings.WorkingDir != oldworkingdir && File.Exists(GitCommands.Settings.WorkingDir + ".gitmodules")) { FormProcess process = new FormProcess(GitCommands.GitCommands.SubmoduleInitCmd("")); process.ShowDialog(); InitializeSubmodulesRecursive(); } Settings.WorkingDir = oldworkingdir; } } Settings.WorkingDir = oldworkingdir; }
private bool ShouldStashPop(bool messageBoxResult, FormProcess process, bool stashed) { return stashed && process != null && !process.ErrorOccurred() && !Module.InTheMiddleOfConflictedMerge() && !Module.InTheMiddleOfRebase() && messageBoxResult; }
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 DialogResult EvaluateProcessDialogResults(IWin32Window owner, FormProcess process, bool stashed) { try { if (EvaluateResultsBasedOnSettings(stashed, process)) return DialogResult.OK; } finally { if (stashed) { bool messageBoxResult = MessageBox.Show(owner, _applyShashedItemsAgain.Text, _applyShashedItemsAgainCaption.Text, MessageBoxButtons.YesNo) == DialogResult.Yes; if (ShouldStashPop(messageBoxResult, process, true)) { FormProcess.ShowDialog(owner, Module, "stash pop"); MergeConflictHandler.HandleMergeConflicts(UICommands, owner, false); } } ScriptManager.RunEventScripts(Module, ScriptEvent.AfterPull); } return DialogResult.No; }
private static void InitSubmodules() { var process = new FormProcess(GitCommandHelpers.SubmoduleInitCmd("")); process.ShowDialog(); InitializeSubmodulesRecursive(); }
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 Ok_Click(object sender, EventArgs e) { try { string dirTo = To.Text; if (!dirTo.EndsWith("\\") && !dirTo.EndsWith("/")) dirTo += "\\"; dirTo += NewDirectory.Text; RepositoryHistory.AddMostRecentRepository(From.Text); RepositoryHistory.AddMostRecentRepository(dirTo); //CloneDto dto = new CloneDto(From.Text, To.Text, CentralRepository.Checked); //GitCommands.Clone commit = new GitCommands.Clone(dto); //commit.Execute(); FormProcess fromProcess; fromProcess = new FormProcess(Settings.GitDir + "git.cmd", GitCommands.GitCommands.CloneCmd(From.Text, dirTo, CentralRepository.Checked)); if (!fromProcess.ErrorOccured() && !GitCommands.GitCommands.InTheMiddleOfPatch()) { if (this.ShowInTaskbar == false) { if (MessageBox.Show("The repository has been cloned successfully." + Environment.NewLine + "Do you want to open the new repository \"" + dirTo + "\" now?", "Open", MessageBoxButtons.YesNo) == DialogResult.Yes) { GitCommands.Settings.WorkingDir = dirTo; if (File.Exists(GitCommands.Settings.WorkingDir + ".gitmodules")) { if (MessageBox.Show("The cloned has submodules configured." + Environment.NewLine + "Do you want to initialize the submodules?" + Environment.NewLine + Environment.NewLine + "This will initialize and update all submodules recursive.", "Submodules", MessageBoxButtons.YesNo) == DialogResult.Yes) { FormProcess process = new FormProcess(GitCommands.GitCommands.SubmoduleInitCmd("")); InitializeSubmodulesRecursive(); } } } } Close(); } } catch { } }
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); } }
public bool StartGitCommandProcessDialog(IWin32Window owner, string arguments) { var process = new FormProcess(arguments); process.ShowDialog(owner); return true; }
public bool StartCommandLineProcessDialog(object owner, string command, string arguments) { var process = new FormProcess(command, arguments); process.ShowDialog(owner as IWin32Window); return true; }
public bool StartCommandLineProcessDialog(GitCommand cmd, Form parentForm) { FormProcess process; if (cmd.AccessesRemote()) process = new FormRemoteProcess(cmd.ToLine()); else process = new FormProcess(cmd.ToLine()); process.ShowDialog(parentForm); return true; }
public bool PullChanges() { if (PullFromUrl.Checked && string.IsNullOrEmpty(PullSource.Text)) { MessageBox.Show(_selectSourceDirectory.Text); return(false); } if (PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text) && !PullAll()) { MessageBox.Show(_selectRemoteRepository.Text); return(false); } if (!Fetch.Checked && Branches.Text == "*") { MessageBox.Show(_fetchAllBranchesCanOnlyWithFetch.Text); return(false); } 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 = PullAll() ? "--all" : Remotes.Text; } ScriptManager.RunEventScripts(ScriptEvent.BeforePull); var stashed = false; if (!Fetch.Checked && AutoStash.Checked && GitCommandHelpers.GitStatus(false).Count > 0) { new FormProcess("stash save").ShowDialog(); stashed = true; } FormProcess process = null; if (Fetch.Checked) { process = new FormProcess(GitCommandHelpers.FetchCmd(source, Branches.Text, null)); } else { string localBranch = GitCommandHelpers.GetSelectedBranch(); if (localBranch.Equals("(no branch)", StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(Branches.Text)) { localBranch = null; } if (Merge.Checked) { process = new FormProcess(GitCommandHelpers.PullCmd(source, Branches.Text, localBranch, false)); } else if (Rebase.Checked) { process = new FormProcess(GitCommandHelpers.PullCmd(source, Branches.Text, localBranch, true)); } } if (process != null) { process.ShowDialog(); } try { if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() && !GitCommandHelpers.InTheMiddleOfRebase() && (process != null && !process.ErrorOccurred())) { return(true); } // Rebase failed -> special 'rebase' merge conflict if (Rebase.Checked && GitCommandHelpers.InTheMiddleOfRebase()) { GitUICommands.Instance.StartRebaseDialog(null); if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() && !GitCommandHelpers.InTheMiddleOfRebase()) { return(true); } } else { MergeConflictHandler.HandleMergeConflicts(); if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() && !GitCommandHelpers.InTheMiddleOfRebase()) { return(true); } } if (!AutoStash.Checked || !stashed || GitCommandHelpers.InTheMiddleOfConflictedMerge() || GitCommandHelpers.InTheMiddleOfRebase()) { return(true); } } finally { if (stashed && process != null && !process.ErrorOccurred() && !GitCommandHelpers.InTheMiddleOfConflictedMerge() && !GitCommandHelpers.InTheMiddleOfRebase() && MessageBox.Show(_applyShashedItemsAgain.Text, _applyShashedItemsAgainCaption.Text, MessageBoxButtons.YesNo) == DialogResult.Yes) { new FormProcess("stash pop").ShowDialog(); MergeConflictHandler.HandleMergeConflicts(); } ScriptManager.RunEventScripts(ScriptEvent.AfterPull); } return(false); }
private bool HandleOnExit(ref bool isError, FormProcess form) { CommandOutput = form.GetOutputString(); var e = new GitRemoteCommandCompletedEventArgs(this, isError, false); if (Completed != null) Completed(form, e); isError = e.IsError; return e.Handled; }
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 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 DoCommit(bool amend) { if (GitCommands.GitCommands.InTheMiddleOfConflictedMerge()) { MessageBox.Show("There are unresolved mergeconflicts, solve mergeconflicts before committing", "Merge conflicts"); return; } if (Message.Text.Length == 0) { MessageBox.Show("Please enter commit message"); return; } if (GitCommands.GitCommands.GetSelectedBranch().CompareTo("(no branch)") == 0) { if (MessageBox.Show("You are not working on a branch." + Environment.NewLine + "This commit will be unreferenced when switching to another brach and can be lost." + Environment.NewLine + "" + Environment.NewLine + "Do you want to continue?", "Not on a branch.", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } try { using (StreamWriter textWriter = new StreamWriter(GitCommands.Settings.WorkingDirGitDir() + "\\COMMITMESSAGE", false)) { textWriter.Write(Message.Text); textWriter.Flush(); textWriter.Close(); } FormProcess form = new FormProcess(GitCommands.GitCommands.CommitCmd(amend)); NeedRefresh = true; if (!form.ErrorOccured()) { Close(); File.Delete(GitCommands.Settings.WorkingDirGitDir() + "\\COMMITMESSAGE"); } } catch(Exception e) { MessageBox.Show("Exception: " + e.Message); } }
private void Push_Click(object sender, EventArgs e) { if (PullFromUrl.Checked && string.IsNullOrEmpty(PushDestination.Text)) { MessageBox.Show("Please select a destination directory"); return; } if (PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text)) { MessageBox.Show("Please select a remote repository"); return; } if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(Tag.Text) && !PushAllTags.Checked) { MessageBox.Show("You need to select a tag to push or select \"Push all tags\"."); return; } GitCommands.RepositoryHistory.AddMostRecentRepository(PushDestination.Text); FormProcess form; if (PullFromUrl.Checked) { if (TabControlTagBranch.SelectedTab == BranchTab) form = new FormProcess(GitCommands.GitCommands.PushCmd(PushDestination.Text, Branch.Text, PushAllBranches.Checked, ForcePushBranches.Checked)); else form = new FormProcess(GitCommands.GitCommands.PushTagCmd(PushDestination.Text, Tag.Text, PushAllTags.Checked, ForcePushBranches.Checked)); } else { if (GitCommands.GitCommands.Plink()) { if (!File.Exists(GitCommands.Settings.Pageant)) MessageBox.Show("Cannot load SSH key. PuTTY is not configured properly.", "PuTTY"); else GitCommands.GitCommands.StartPageantForRemote(Remotes.Text); } if (TabControlTagBranch.SelectedTab == BranchTab) form = new FormProcess(GitCommands.Settings.GitCommand, GitCommands.GitCommands.PushCmd(Remotes.Text, Branch.Text, PushAllBranches.Checked, ForcePushBranches.Checked), Remotes.Text.Trim()); else form = new FormProcess(GitCommands.Settings.GitCommand, GitCommands.GitCommands.PushTagCmd(Remotes.Text, Tag.Text, PushAllTags.Checked, ForcePushBranches.Checked), Remotes.Text.Trim()); } if (!GitCommands.GitCommands.InTheMiddleOfConflictedMerge() && !GitCommands.GitCommands.InTheMiddleOfRebase() && !form.ErrorOccured()) Close(); }
private void ShowFilesClick(object sender, EventArgs e) { FormProcess.ShowDialog(this, string.Format("add --dry-run{0} \"{1}\"", force.Checked ? " -f" : "", Filter.Text), false); }