IObservable <Unit> OnCloneRepository(object state) { return(Observable.Start(() => { var repository = SelectedRepository; Debug.Assert(repository != null, "Should not be able to attempt to clone a repo when it's null"); // The following is a noop if the directory already exists. operatingSystem.Directory.CreateDirectory(BaseRepositoryPath); return cloneService.CloneRepository(repository.CloneUrl, repository.Name, BaseRepositoryPath); }) .SelectMany(_ => _) .Catch <Unit, Exception>(e => { var repository = SelectedRepository; Debug.Assert(repository != null, "Should not be able to attempt to clone a repo when it's null"); vsServices.ShowError(e.GetUserFriendlyErrorMessage(ErrorType.ClonedFailed, repository.Name)); return Observable.Return(Unit.Default); })); }
private IObservable <Unit> OnPublishRepository(object arg) { var newRepository = GatherRepositoryInfo(); var account = SelectedAccount; return(repositoryPublishService.PublishRepository(newRepository, account, SelectedHost.ApiClient) .SelectUnit() .Do(_ => vsServices.ShowMessage("Repository published successfully.")) .Catch <Unit, Exception>(ex => { if (!ex.IsCriticalException()) { log.Error(ex); var error = new PublishRepositoryUserError(ex.Message); vsServices.ShowError((error.ErrorMessage + Environment.NewLine + error.ErrorCauseOrResolution).TrimEnd()); } return Observable.Return(Unit.Default); })); }
IObservable <ProgressState> OnPublishRepository(object arg) { var newRepository = GatherRepositoryInfo(); var account = SelectedAccount; return(repositoryPublishService.PublishRepository(newRepository, account, SelectedHost.ApiClient) .Select(_ => { vsServices.ShowMessage("Repository published successfully."); return ProgressState.Success; }) .Catch <ProgressState, Exception>(ex => { if (!ex.IsCriticalException()) { log.Error(ex); var error = new PublishRepositoryUserError(ex.Message); vsServices.ShowError((error.ErrorMessage + Environment.NewLine + error.ErrorCauseOrResolution).TrimEnd()); } return Observable.Return(ProgressState.Fail); })); }