private void RunSetAndApplyBranchFilterTest(string initialFilter, Action <RevisionGridControl> runTest) { // Disable artificial commits as they appear to destabilise these tests AppSettings.RevisionGraphShowArtificialCommits = false; UITest.RunForm <FormBrowse>( showForm: () => _commands.StartBrowseDialog(owner: null).Should().BeTrue(), runTestAsync: async formBrowse => { DoEvents(); // wait for the revisions to be loaded await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); formBrowse.RevisionGridControl.SetSelectedRevision(ObjectId.Parse(_headCommit)); formBrowse.RevisionGridControl.SetAndApplyBranchFilter(initialFilter, requireRefresh: true); // wait for the revisions to be loaded await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); try { runTest(formBrowse.RevisionGridControl); } catch (Exception ex) { Console.WriteLine($"{runTest.Method.Name} failed: {ex.Demystify()}"); Console.WriteLine(_referenceRepository.Module.GitExecutable.GetOutput("status")); throw; } }); }
private void RunSetAndApplyBranchFilterTest(string initialFilter, Action <RevisionGridControl> runTest) { UITest.RunForm <FormBrowse>( showForm: () => _commands.StartBrowseDialog(owner: null).Should().BeTrue(), runTestAsync: async formBrowse => { DoEvents(); // wait for the revisions to be loaded await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); formBrowse.RevisionGridControl.SetAndApplyBranchFilter(initialFilter); // Refresh the grid, to reflect the filter formBrowse.RevisionGridControl.ForceRefreshRevisions(); DoEvents(); try { runTest(formBrowse.RevisionGridControl); } catch (Exception ex) { Console.WriteLine($"{runTest.Method.Name} failed: {ex.Demystify()}"); Console.WriteLine(_referenceRepository.Module.GitExecutable.GetOutput("status")); throw; } }); }
private void RunFormTest(Func <FormBrowse, Task> testDriverAsync) { UITest.RunForm( () => { Assert.True(_commands.StartBrowseDialog(owner: null)); }, testDriverAsync); }
private static void RunFormTest(Action <FormBrowse> testDriver, GitUICommands commands) { UITest.RunForm( showForm: () => commands.StartBrowseDialog(owner: null).Should().BeTrue(), (FormBrowse form) => { testDriver(form); return(Task.CompletedTask); }); }
private void OkClick(object sender, EventArgs e) { try { Cursor = Cursors.Default; _branchListLoader.Cancel(); var dirTo = _NO_TRANSLATE_To.Text; if (!dirTo.EndsWith(AppSettings.PathSeparator.ToString()) && !dirTo.EndsWith(AppSettings.PathSeparatorWrong.ToString())) { dirTo += AppSettings.PathSeparator.ToString(); } dirTo += _NO_TRANSLATE_NewDirectory.Text; Repositories.AddMostRecentRepository(_NO_TRANSLATE_From.Text); Repositories.AddMostRecentRepository(dirTo); if (!Directory.Exists(dirTo)) { Directory.CreateDirectory(dirTo); } var cloneCmd = GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo, CentralRepository.Checked, cbIntializeAllSubmodules.Checked, Branches.Text, null); using (var fromProcess = new FormRemoteProcess(Module, AppSettings.GitCommand, cloneCmd)) { fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text); fromProcess.ShowDialog(this); if (fromProcess.ErrorOccurred() || Module.InTheMiddleOfPatch()) { return; } } if (openedFromProtocolHandler && AskIfNewRepositoryShouldBeOpened(dirTo)) { Hide(); GitUICommands uiCommands = new GitUICommands(dirTo); uiCommands.StartBrowseDialog(); } else if (ShowInTaskbar == false && GitModuleChanged != null && AskIfNewRepositoryShouldBeOpened(dirTo)) { GitModuleChanged(new GitModule(dirTo)); } Close(); } catch (Exception ex) { MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void RunFormTest(Func <FormBrowse, Task> testDriverAsync) { // Needed for FormBrowse, ScriptOptionsParser ManagedExtensibility.Initialise(new[] { typeof(GitUI.GitExtensionsForm).Assembly, typeof(GitCommands.GitModule).Assembly }); UITest.RunForm( showForm: () => _uiCommands.StartBrowseDialog(owner: null).Should().BeTrue(), testDriverAsync); }
private void RunToggleBetweenArtificialAndHeadCommitsTest(bool showGitStatusForArtificialCommits, Action <RevisionGridControl> runTest) { AppSettings.ShowGitStatusForArtificialCommits = showGitStatusForArtificialCommits; UITest.RunForm <FormBrowse>( showForm: () => _commands.StartBrowseDialog(owner: null).Should().BeTrue(), runTestAsync: async formBrowse => { DoEvents(); // wait for the revisions to be loaded await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); formBrowse.RevisionGridControl.LatestSelectedRevision.Guid.Should().Be(_headCommit); var ta = formBrowse.GetTestAccessor(); ta.CommitInfoTabControl.SelectedTab = ta.TreeTabPage; // let the focus events be handled DoEvents(); try { runTest(formBrowse.RevisionGridControl); } catch (Exception ex) { Console.WriteLine($"{runTest.Method.Name} failed: {ex.Demystify()}"); Console.WriteLine(_referenceRepository.Module.GitExecutable.GetOutput("status")); } // let the focus events be handled DoEvents(); Assert.IsTrue(ta.CommitInfoTabControl.SelectedTab == ta.DiffTabPage, "Diff tab should be active"); return;
private static void RunApplication() { string[] args = Environment.GetCommandLineArgs(); // This form created for obtain UI synchronization context only using (new Form()) { // Store here SynchronizationContext.Current, because later sometimes it can be null // see http://stackoverflow.com/questions/11621372/synchronizationcontext-current-is-null-in-continuation-on-the-main-ui-thread GitUIExtensions.UISynchronizationContext = SynchronizationContext.Current; AsyncLoader.DefaultContinuationTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); } AppSettings.LoadSettings(); if (EnvUtils.RunningOnWindows()) { WebBrowserEmulationMode.SetBrowserFeatureControl(); FormFixHome.CheckHomePath(); } if (string.IsNullOrEmpty(AppSettings.Translation)) { using (var formChoose = new FormChooseTranslation()) { formChoose.ShowDialog(); } } try { if (!(args.Length >= 2 && args[1].Equals("uninstall")) && (AppSettings.CheckSettings || string.IsNullOrEmpty(AppSettings.GitCommandValue) || !File.Exists(AppSettings.GitCommandValue))) { GitUICommands uiCommands = new GitUICommands(string.Empty); var commonLogic = new CommonLogic(uiCommands.Module); var checkSettingsLogic = new CheckSettingsLogic(commonLogic); ISettingsPageHost fakePageHost = new SettingsPageHostMock(checkSettingsLogic); using (var checklistSettingsPage = SettingsPageBase.Create <ChecklistSettingsPage>(fakePageHost)) { if (!checklistSettingsPage.CheckSettings()) { if (!checkSettingsLogic.AutoSolveAllSettings()) { uiCommands.StartSettingsDialog(); } } } } } catch { // TODO: remove catch-all } if (EnvUtils.RunningOnWindows()) { MouseWheelRedirector.Active = true; } GitUICommands commands = new GitUICommands(GetWorkingDir(args)); if (args.Length <= 1) { commands.StartBrowseDialog(); } else { // if we are here args.Length > 1 commands.RunCommand(args); } AppSettings.SaveSettings(); }
private static void RunApplication() { string[] args = Environment.GetCommandLineArgs(); // This form created to obtain UI synchronization context only using (new Form()) { // Store the shared JoinableTaskContext ThreadHelper.JoinableTaskContext = new JoinableTaskContext(); } AppSettings.LoadSettings(); if (EnvUtils.RunningOnWindows()) { WebBrowserEmulationMode.SetBrowserFeatureControl(); FormFixHome.CheckHomePath(); } if (string.IsNullOrEmpty(AppSettings.Translation)) { using (var formChoose = new FormChooseTranslation()) { formChoose.ShowDialog(); } } if (!AppSettings.TelemetryEnabled.HasValue) { AppSettings.TelemetryEnabled = MessageBox.Show(null, Strings.TelemetryPermissionMessage, Strings.TelemetryPermissionCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; } try { // Ensure we can find the git command to execute, // unless we are being instructed to uninstall, // or AppSettings.CheckSettings is set to false. if (!(args.Length >= 2 && args[1] == "uninstall")) { if (!CheckSettingsLogic.SolveGitCommand()) { if (!LocateMissingGit()) { Environment.Exit(-1); return; } } if (AppSettings.CheckSettings) { var uiCommands = new GitUICommands(""); var commonLogic = new CommonLogic(uiCommands.Module); var checkSettingsLogic = new CheckSettingsLogic(commonLogic); var fakePageHost = new SettingsPageHostMock(checkSettingsLogic); using (var checklistSettingsPage = SettingsPageBase.Create <ChecklistSettingsPage>(fakePageHost)) { if (!checklistSettingsPage.CheckSettings()) { if (!checkSettingsLogic.AutoSolveAllSettings()) { uiCommands.StartSettingsDialog(); } } } } } } catch { // TODO: remove catch-all } if (EnvUtils.RunningOnWindows()) { MouseWheelRedirector.Active = true; } var commands = new GitUICommands(GetWorkingDir(args)); if (args.Length <= 1) { commands.StartBrowseDialog(); } else { // if we are here args.Length > 1 // Avoid replacing the ExitCode eventually set while parsing arguments, // i.e. assume -1 and afterwards, only set it to 0 if no error is indicated. Environment.ExitCode = -1; if (commands.RunCommand(args)) { Environment.ExitCode = 0; } } AppSettings.SaveSettings(); }
private void OkClick(object sender, EventArgs e) { try { Cursor = Cursors.Default; _branchListLoader.Cancel(); // validate if destination path is supplied var destination = _NO_TRANSLATE_To.Text; if (string.IsNullOrWhiteSpace(destination)) { MessageBox.Show(this, _errorDestinationNotSupplied.Text, _errorCloneFailed.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); _NO_TRANSLATE_To.Focus(); return; } if (!Path.IsPathRooted(destination)) { MessageBox.Show(this, _errorDestinationNotRooted.Text, _errorCloneFailed.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); _NO_TRANSLATE_To.Focus(); return; } var dirTo = Path.Combine(destination, _NO_TRANSLATE_NewDirectory.Text); // this will fail if the path is anyhow invalid dirTo = new Uri(dirTo).LocalPath; if (!Directory.Exists(dirTo)) { Directory.CreateDirectory(dirTo); } // Shallow clone params int? depth = null; bool?isSingleBranch = null; if (!cbDownloadFullHistory.Checked) { depth = 1; // Single branch considerations: // If neither depth nor single-branch family params are specified, then it's like no-single-branch by default. // If depth is specified, then single-branch is assumed. // But with single-branch it's really nontrivial to switch to another branch in the GUI, and it's very hard in cmdline (obvious choices to fetch another branch lead to local repo corruption). // So let's reset it to no-single-branch to (a) have the same branches behavior as with full clone, and (b) make it easier for users when switching branches. isSingleBranch = false; } // Branch name param string branch = _NO_TRANSLATE_Branches.Text; if (branch == _branchDefaultRemoteHead.Text) { branch = ""; } else if (branch == _branchNone.Text) { branch = null; } var cloneCmd = GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo, CentralRepository.Checked, cbIntializeAllSubmodules.Checked, branch, depth, isSingleBranch, cbLfs.Checked); using (var fromProcess = new FormRemoteProcess(Module, AppSettings.GitCommand, cloneCmd)) { fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text); fromProcess.ShowDialog(this); if (fromProcess.ErrorOccurred() || Module.InTheMiddleOfPatch()) { return; } } ThreadHelper.JoinableTaskFactory.Run(() => RepositoryHistoryManager.Locals.AddAsMostRecentAsync(dirTo)); if (!string.IsNullOrEmpty(_puttySshKey)) { var clonedGitModule = new GitModule(dirTo); clonedGitModule.SetSetting(string.Format(SettingKeyString.RemotePuttySshKey, "origin"), _puttySshKey); clonedGitModule.LocalConfigFile.Save(); } if (_openedFromProtocolHandler && AskIfNewRepositoryShouldBeOpened(dirTo)) { Hide(); var uiCommands = new GitUICommands(dirTo); uiCommands.StartBrowseDialog(); } else if (ShowInTaskbar == false && _gitModuleChanged != null && AskIfNewRepositoryShouldBeOpened(dirTo)) { _gitModuleChanged(this, new GitModuleEventArgs(new GitModule(dirTo))); } Close(); } catch (Exception ex) { MessageBox.Show(this, "Exception: " + ex.Message, _errorCloneFailed.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OkClick(object sender, EventArgs e) { try { Cursor = Cursors.Default; _branchListLoader.Cancel(); var dirTo = _NO_TRANSLATE_To.Text; if (!dirTo.EndsWith(AppSettings.PathSeparator.ToString()) && !dirTo.EndsWith(AppSettings.PathSeparatorWrong.ToString())) dirTo += AppSettings.PathSeparator.ToString(); dirTo += _NO_TRANSLATE_NewDirectory.Text; Repositories.AddMostRecentRepository(_NO_TRANSLATE_From.Text); Repositories.AddMostRecentRepository(dirTo); if (!Directory.Exists(dirTo)) Directory.CreateDirectory(dirTo); var cloneCmd = GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo, CentralRepository.Checked, cbIntializeAllSubmodules.Checked, Branches.Text, null); using (var fromProcess = new FormRemoteProcess(Module, AppSettings.GitCommand, cloneCmd)) { fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text); fromProcess.ShowDialog(this); if (fromProcess.ErrorOccurred() || Module.InTheMiddleOfPatch()) return; } if (openedFromProtocolHandler && AskIfNewRepositoryShouldBeOpened(dirTo)) { Hide(); GitUICommands uiCommands = new GitUICommands(dirTo); uiCommands.StartBrowseDialog(); } else if (ShowInTaskbar == false && GitModuleChanged != null && AskIfNewRepositoryShouldBeOpened(dirTo)) GitModuleChanged(new GitModule(dirTo)); Close(); } catch (Exception ex) { MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (Settings.RunningOnWindows()) { NBug.Settings.UIMode = NBug.Enums.UIMode.Full; // Uncomment the following after testing to see that NBug is working as configured NBug.Settings.ReleaseMode = true; NBug.Settings.ExitApplicationImmediately = false; NBug.Settings.WriteLogToDisk = true; NBug.Settings.MaxQueuedReports = 10; AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException; Application.ThreadException += NBug.Handler.ThreadException; } string[] args = Environment.GetCommandLineArgs(); FormSplash.ShowSplash(); Application.DoEvents(); Settings.LoadSettings(); if (Settings.RunningOnWindows()) { //Quick HOME check: FormSplash.SetAction("Checking home path..."); Application.DoEvents(); FormFixHome.CheckHomePath(); } //Register plugins FormSplash.SetAction("Loading plugins..."); Application.DoEvents(); if (string.IsNullOrEmpty(Settings.Translation)) { using (var formChoose = new FormChooseTranslation()) { formChoose.ShowDialog(); } } try { if (Application.UserAppDataRegistry == null || Settings.GetValue <string>("checksettings", null) == null || !Settings.GetValue <string>("checksettings", null).Equals("false", StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(Settings.GitCommand)) { FormSplash.SetAction("Checking settings..."); Application.DoEvents(); GitUICommands uiCommands = new GitUICommands(string.Empty); using (var settings = new FormSettings(uiCommands)) { if (!settings.CheckSettings()) { settings.AutoSolveAllSettings(); uiCommands.StartSettingsDialog(); } } } } catch { // TODO: remove catch-all } FormSplash.HideSplash(); if (Settings.RunningOnWindows()) { MouseWheelRedirector.Active = true; } GitUICommands uCommands = new GitUICommands(GetWorkingDir(args)); if (args.Length <= 1) { uCommands.StartBrowseDialog(); } else // if we are here args.Length > 1 { uCommands.RunCommand(args); } Settings.SaveSettings(); }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!EnvUtils.IsMonoRuntime()) { NBug.Settings.UIMode = NBug.Enums.UIMode.Full; // Uncomment the following after testing to see that NBug is working as configured NBug.Settings.ReleaseMode = true; NBug.Settings.ExitApplicationImmediately = false; NBug.Settings.WriteLogToDisk = true; NBug.Settings.MaxQueuedReports = 10; NBug.Settings.StopReportingAfter = 90; NBug.Settings.SleepBeforeSend = 30; NBug.Settings.StoragePath = "WindowsTemp"; AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException; Application.ThreadException += NBug.Handler.ThreadException; } string[] args = Environment.GetCommandLineArgs(); FormSplash.ShowSplash(); //Store here SynchronizationContext.Current, because later sometimes it can be null //see http://stackoverflow.com/questions/11621372/synchronizationcontext-current-is-null-in-continuation-on-the-main-ui-thread GitUIExtensions.UISynchronizationContext = SynchronizationContext.Current; Application.DoEvents(); Settings.LoadSettings(); if (EnvUtils.RunningOnWindows()) { //Quick HOME check: FormSplash.SetAction("Checking home path..."); Application.DoEvents(); FormFixHome.CheckHomePath(); } //Register plugins FormSplash.SetAction("Loading plugins..."); Application.DoEvents(); if (string.IsNullOrEmpty(Settings.Translation)) { using (var formChoose = new FormChooseTranslation()) { formChoose.ShowDialog(); } } try { if (Application.UserAppDataRegistry == null || Settings.GetBool("checksettings", true) || string.IsNullOrEmpty(Settings.GitCommand)) { FormSplash.SetAction("Checking settings..."); Application.DoEvents(); GitUICommands uiCommands = new GitUICommands(string.Empty); var commonLogic = new CommonLogic(uiCommands.Module); var checkSettingsLogic = new CheckSettingsLogic(commonLogic, uiCommands.Module); using (var checklistSettingsPage = new ChecklistSettingsPage(commonLogic, checkSettingsLogic, uiCommands.Module, null)) { if (!checklistSettingsPage.CheckSettings()) { checkSettingsLogic.AutoSolveAllSettings(); uiCommands.StartSettingsDialog(); } } } } catch { // TODO: remove catch-all } FormSplash.HideSplash(); if (EnvUtils.RunningOnWindows()) { MouseWheelRedirector.Active = true; } GitUICommands uCommands = new GitUICommands(GetWorkingDir(args)); if (args.Length <= 1) { uCommands.StartBrowseDialog(); } else // if we are here args.Length > 1 { uCommands.RunCommand(args); } Settings.SaveSettings(); }
private static void RunApplication() { string[] args = Environment.GetCommandLineArgs(); // This form created for obtain UI synchronization context only using (new Form()) { // Store the shared JoinableTaskContext ThreadHelper.JoinableTaskContext = new JoinableTaskContext(); } AppSettings.LoadSettings(); if (EnvUtils.RunningOnWindows()) { WebBrowserEmulationMode.SetBrowserFeatureControl(); FormFixHome.CheckHomePath(); } if (string.IsNullOrEmpty(AppSettings.Translation)) { using (var formChoose = new FormChooseTranslation()) { formChoose.ShowDialog(); } } try { if (!(args.Length >= 2 && args[1] == "uninstall") && (AppSettings.CheckSettings || string.IsNullOrEmpty(AppSettings.GitCommandValue) || !File.Exists(AppSettings.GitCommandValue))) { GitUICommands uiCommands = new GitUICommands(string.Empty); var commonLogic = new CommonLogic(uiCommands.Module); var checkSettingsLogic = new CheckSettingsLogic(commonLogic); ISettingsPageHost fakePageHost = new SettingsPageHostMock(checkSettingsLogic); using (var checklistSettingsPage = SettingsPageBase.Create <ChecklistSettingsPage>(fakePageHost)) { if (!checklistSettingsPage.CheckSettings()) { if (!checkSettingsLogic.AutoSolveAllSettings()) { uiCommands.StartSettingsDialog(); } } } } } catch { // TODO: remove catch-all } if (EnvUtils.RunningOnWindows()) { MouseWheelRedirector.Active = true; } GitUICommands commands = new GitUICommands(GetWorkingDir(args)); if (args.Length <= 1) { commands.StartBrowseDialog(startWithDashboard: !AppSettings.StartWithRecentWorkingDir); } else { // if we are here args.Length > 1 commands.RunCommand(args); } AppSettings.SaveSettings(); }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!EnvUtils.IsMonoRuntime()) { try { NBug.Settings.UIMode = NBug.Enums.UIMode.Full; // Uncomment the following after testing to see that NBug is working as configured NBug.Settings.ReleaseMode = true; NBug.Settings.ExitApplicationImmediately = false; NBug.Settings.WriteLogToDisk = false; NBug.Settings.MaxQueuedReports = 10; NBug.Settings.StopReportingAfter = 90; NBug.Settings.SleepBeforeSend = 30; NBug.Settings.StoragePath = NBug.Enums.StoragePath.WindowsTemp; AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException; Application.ThreadException += NBug.Handler.ThreadException; } catch (TypeInitializationException tie) { // is this exception caused by the configuration? if (tie.InnerException != null && tie.InnerException.GetType() .IsSubclassOf(typeof(System.Configuration.ConfigurationException))) { HandleConfigurationException((System.Configuration.ConfigurationException)tie.InnerException); } } } string[] args = Environment.GetCommandLineArgs(); FormSplash.ShowSplash(); //Store here SynchronizationContext.Current, because later sometimes it can be null //see http://stackoverflow.com/questions/11621372/synchronizationcontext-current-is-null-in-continuation-on-the-main-ui-thread GitUIExtensions.UISynchronizationContext = SynchronizationContext.Current; AsyncLoader.DefaultContinuationTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); Application.DoEvents(); AppSettings.LoadSettings(); if (EnvUtils.RunningOnWindows()) { WebBrowserEmulationMode.SetBrowserFeatureControl(); //Quick HOME check: FormSplash.SetAction("Checking home path..."); Application.DoEvents(); FormFixHome.CheckHomePath(); } //Register plugins FormSplash.SetAction("Loading plugins..."); Application.DoEvents(); if (string.IsNullOrEmpty(AppSettings.Translation)) { using (var formChoose = new FormChooseTranslation()) { formChoose.ShowDialog(); } } try { if (!(args.Length >= 2 && args[1].Equals("uninstall")) && (AppSettings.CheckSettings || string.IsNullOrEmpty(AppSettings.GitCommandValue) || !File.Exists(AppSettings.GitCommandValue))) { FormSplash.SetAction("Checking settings..."); Application.DoEvents(); GitUICommands uiCommands = new GitUICommands(string.Empty); var commonLogic = new CommonLogic(uiCommands.Module); var checkSettingsLogic = new CheckSettingsLogic(commonLogic); ISettingsPageHost fakePageHost = new SettingsPageHostMock(checkSettingsLogic); using (var checklistSettingsPage = SettingsPageBase.Create <ChecklistSettingsPage>(fakePageHost)) { if (!checklistSettingsPage.CheckSettings()) { if (!checkSettingsLogic.AutoSolveAllSettings()) { uiCommands.StartSettingsDialog(); } } } } } catch { // TODO: remove catch-all } FormSplash.HideSplash(); if (EnvUtils.RunningOnWindows()) { MouseWheelRedirector.Active = true; } GitUICommands uCommands = new GitUICommands(GetWorkingDir(args)); if (args.Length <= 1) { uCommands.StartBrowseDialog(); } else // if we are here args.Length > 1 { uCommands.RunCommand(args); } AppSettings.SaveSettings(); }
private static void RunApplication() { string[] args = Environment.GetCommandLineArgs(); // This form created to obtain UI synchronization context only using (new Form()) { // Store the shared JoinableTaskContext ThreadHelper.JoinableTaskContext = new JoinableTaskContext(); } AppSettings.LoadSettings(); if (EnvUtils.RunningOnWindows()) { WebBrowserEmulationMode.SetBrowserFeatureControl(); FormFixHome.CheckHomePath(); } if (string.IsNullOrEmpty(AppSettings.Translation)) { using (var formChoose = new FormChooseTranslation()) { formChoose.ShowDialog(); } } try { // Ensure we can find the git command to execute, // unless we are being instructed to uninstall, // or AppSettings.CheckSettings is set to false. if (!(args.Length >= 2 && args[1] == "uninstall")) { if (!CheckSettingsLogic.SolveGitCommand()) { if (!LocateMissingGit()) { Environment.Exit(-1); return; } } if (AppSettings.CheckSettings) { var uiCommands = new GitUICommands(""); var commonLogic = new CommonLogic(uiCommands.Module); var checkSettingsLogic = new CheckSettingsLogic(commonLogic); var fakePageHost = new SettingsPageHostMock(checkSettingsLogic); using (var checklistSettingsPage = SettingsPageBase.Create <ChecklistSettingsPage>(fakePageHost)) { if (!checklistSettingsPage.CheckSettings()) { if (!checkSettingsLogic.AutoSolveAllSettings()) { uiCommands.StartSettingsDialog(); } } } } } } catch { // TODO: remove catch-all } if (EnvUtils.RunningOnWindows()) { MouseWheelRedirector.Active = true; } var commands = new GitUICommands(GetWorkingDir(args)); if (args.Length <= 1) { commands.StartBrowseDialog(); } else { // if we are here args.Length > 1 commands.RunCommand(args); } AppSettings.SaveSettings(); }
private void OkClick(object sender, EventArgs e) { try { Cursor = Cursors.Default; _branchListLoader.Cancel(); var dirTo = Path.Combine(_NO_TRANSLATE_To.Text, _NO_TRANSLATE_NewDirectory.Text); Repositories.AddMostRecentRepository(_NO_TRANSLATE_From.Text); if (!Directory.Exists(dirTo)) { Directory.CreateDirectory(dirTo); } // Shallow clone params int? depth = null; bool?isSingleBranch = null; if (!cbDownloadFullHistory.Checked) { depth = 1; // Single branch considerations: // If neither depth nor single-branch family params are specified, then it's like no-single-branch by default. // If depth is specified, then single-branch is assumed. // But with single-branch it's really nontrivial to switch to another branch in the GUI, and it's very hard in cmdline (obvious choices to fetch another branch lead to local repo corruption). // So let's reset it to no-single-branch to (a) have the same branches behavior as with full clone, and (b) make it easier for users when switching branches. isSingleBranch = false; } // Branch name param string branch = _NO_TRANSLATE_Branches.Text; if (branch == _branchDefaultRemoteHead.Text) { branch = ""; } else if (branch == _branchNone.Text) { branch = null; } var cloneCmd = GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo, CentralRepository.Checked, cbIntializeAllSubmodules.Checked, branch, depth, isSingleBranch); using (var fromProcess = new FormRemoteProcess(Module, AppSettings.GitCommand, cloneCmd)) { fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text); fromProcess.ShowDialog(this); if (fromProcess.ErrorOccurred() || Module.InTheMiddleOfPatch()) { return; } } Repositories.AddMostRecentRepository(dirTo); if (openedFromProtocolHandler && AskIfNewRepositoryShouldBeOpened(dirTo)) { Hide(); GitUICommands uiCommands = new GitUICommands(dirTo); uiCommands.StartBrowseDialog(); } else if (ShowInTaskbar == false && GitModuleChanged != null && AskIfNewRepositoryShouldBeOpened(dirTo)) { GitModuleChanged(this, new GitModuleEventArgs(new GitModule(dirTo))); } Close(); } catch (Exception ex) { MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void RunFormTest(Func <FormBrowse, Task> testDriverAsync) { UITest.RunForm( showForm: () => _uiCommands.StartBrowseDialog(owner: null).Should().BeTrue(), testDriverAsync); }
private void OkClick(object sender, EventArgs e) { try { Cursor = Cursors.Default; _branchListLoader.Cancel(); var dirTo = Path.Combine(_NO_TRANSLATE_To.Text, _NO_TRANSLATE_NewDirectory.Text); Repositories.AddMostRecentRepository(_NO_TRANSLATE_From.Text); if (!Directory.Exists(dirTo)) Directory.CreateDirectory(dirTo); // Shallow clone params int? depth = null; bool? isSingleBranch = null; if(!cbDownloadFullHistory.Checked) { depth = 1; // Single branch considerations: // If neither depth nor single-branch family params are specified, then it's like no-single-branch by default. // If depth is specified, then single-branch is assumed. // But with single-branch it's really nontrivial to switch to another branch in the GUI, and it's very hard in cmdline (obvious choices to fetch another branch lead to local repo corruption). // So let's reset it to no-single-branch to (a) have the same branches behavior as with full clone, and (b) make it easier for users when switching branches. isSingleBranch = false; } // Branch name param string branch = _NO_TRANSLATE_Branches.Text; if(branch == _branchDefaultRemoteHead.Text) branch = ""; else if(branch == _branchNone.Text) branch = null; var cloneCmd = GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo, CentralRepository.Checked, cbIntializeAllSubmodules.Checked, branch, depth, isSingleBranch); using (var fromProcess = new FormRemoteProcess(Module, AppSettings.GitCommand, cloneCmd)) { fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text); fromProcess.ShowDialog(this); if (fromProcess.ErrorOccurred() || Module.InTheMiddleOfPatch()) return; } Repositories.AddMostRecentRepository(dirTo); if (openedFromProtocolHandler && AskIfNewRepositoryShouldBeOpened(dirTo)) { Hide(); GitUICommands uiCommands = new GitUICommands(dirTo); uiCommands.StartBrowseDialog(); } else if (ShowInTaskbar == false && GitModuleChanged != null && AskIfNewRepositoryShouldBeOpened(dirTo)) GitModuleChanged(this, new GitModuleEventArgs(new GitModule(dirTo))); Close(); } catch (Exception ex) { MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }