private static async Task <bool> InitializeGitAsync(ITeamExplorerUtils teamExplorer) { if (s_gitInited) { return(true); } return(s_gitInited = (await SetUseHttpPathAsync(teamExplorer)) && SetGitCredential(teamExplorer)); }
public CsrReposViewModel(ITeamExplorerUtils teamExplorer) { _teamExplorer = teamExplorer.ThrowIfNull(nameof(teamExplorer)); ListDoubleClickCommand = new ProtectedCommand(() => { SetRepoActive(SelectedRepository); // Note, the order is critical. // When switching to HomeSection, current "this" object is destroyed. _teamExplorer.ShowHomeSection(); }); CloneCreateRepoCommand = new ProtectedAsyncCommand(CloneCreateRepoAsync); }
private static bool SetGitCredential(ITeamExplorerUtils teamExplorer) { if (CredentialsStore.Default.CurrentAccount != null) { if (!CsrGitUtils.StoreCredential( CsrGitUtils.CsrUrlAuthority, CredentialsStore.Default.CurrentAccount.RefreshToken, CsrGitUtils.StoreCredentialPathOption.UrlHost)) { teamExplorer.ShowError(Resources.GitInitilizationFailedMessage); return(s_gitInited = false); } } return(true); }
private static async Task <bool> SetUseHttpPathAsync(ITeamExplorerUtils teamExplorer) { bool ret; try { await CsrGitUtils.SetUseHttpPathAsync(); ret = true; } catch (GitCommandException) { ret = false; } if (!ret) { teamExplorer.ShowError(Resources.GitInitilizationFailedMessage); } return(ret); }
async Task ISectionViewModel.InitializeAsync(ITeamExplorerUtils teamExplorerService) { // When the user switches to TeamExplorer immediately after opening Visual Studio, // sometimes, GoogleCloudExtensionPackage is not initialized. This is a hack to // retry until the instance is initialized. int retryAttempts = 3; while (retryAttempts > 0 && GoogleCloudExtensionPackage.Instance == null) { await Task.Delay(2000); retryAttempts--; } if (GoogleCloudExtensionPackage.Instance == null) { teamExplorerService.ShowError(Resources.FailedLoadingCsr); return; } EventsReporterWrapper.ReportEvent(CsrConnectSectionOpenEvent.Create()); Debug.WriteLine("CsrSectionControlViewModel Initialize"); _teamExplorerService = teamExplorerService.ThrowIfNull(nameof(teamExplorerService)); _reposViewModel = new CsrReposViewModel(_teamExplorerService); _reposContent.DataContext = _reposViewModel; _unconnectedViewModel = new CsrUnconnectedViewModel(this); _unconnectedContent.DataContext = _unconnectedViewModel; _gitSetupViewModel = new CsrGitSetupWarningViewModel(this); _gitSetupContent.DataContext = _gitSetupViewModel; if (!CsrGitSetupWarningViewModel.GitInstallationVerified) { ErrorHandlerUtils.HandleExceptionsAsync(CheckGitInstallationAsync); } else { OnGitInstallationCheckSuccess(); } }
void ISectionViewModel.Initialize(ITeamExplorerUtils teamExplorerService) { EventsReporterWrapper.ReportEvent(CsrConnectSectionOpenEvent.Create()); Debug.WriteLine("CsrSectionControlViewModel Initialize"); _teamExplorerService = teamExplorerService.ThrowIfNull(nameof(teamExplorerService)); _reposViewModel = new CsrReposViewModel(_teamExplorerService); _reposContent.DataContext = _reposViewModel; _unconnectedViewModel = new CsrUnconnectedViewModel(this); _unconnectedContent.DataContext = _unconnectedViewModel; _gitSetupViewModel = new CsrGitSetupWarningViewModel(this); _gitSetupContent.DataContext = _gitSetupViewModel; if (!CsrGitSetupWarningViewModel.GitInstallationVerified) { ErrorHandlerUtils.HandleExceptionsAsync(CheckGitInstallationAsync); } else { OnGitInstallationCheckSuccess(); } }