예제 #1
0
        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");
                if (repository == null)
                {
                    notificationService.ShowError(Resources.RepositoryCloneFailedNoSelectedRepo);
                    return Observable.Return(Unit.Default);
                }

                // The following is a noop if the directory already exists.
                operatingSystem.Directory.CreateDirectory(BaseRepositoryPath);

                return cloneService.CloneRepository(repository.CloneUrl, repository.Name, BaseRepositoryPath)
                .ContinueAfter(() =>
                {
                    usageTracker.IncrementCloneCount();
                    return Observable.Return(Unit.Default);
                });
            })
                   .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");
                notificationService.ShowError(e.GetUserFriendlyErrorMessage(ErrorType.ClonedFailed, repository.Name));
                return Observable.Return(Unit.Default);
            }));
        }
예제 #2
0
        public IObservable <Unit> CreateRepository(
            NewRepository newRepository,
            IAccount account,
            string directory,
            IApiClient apiClient)
        {
            Guard.ArgumentNotEmptyString(directory, nameof(directory));

            return(apiClient.CreateRepository(newRepository, account.Login, account.IsUser)
                   .Select(repository => cloneService.CloneRepository(repository.CloneUrl, repository.Name, directory))
                   .SelectUnit());
        }
 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);
     }));
 }