Beispiel #1
0
        IObservable <Unit> DoCheckout(object unused)
        {
            IObservable <Unit> operation = null;

            switch (CheckoutMode)
            {
            case CheckoutMode.NeedsPull:
                operation = pullRequestsService.Pull(repository);
                break;

            case CheckoutMode.Fetch:
                operation = pullRequestsService
                            .GetDefaultLocalBranchName(repository, Model.Number, Model.Title)
                            .SelectMany(x => pullRequestsService.FetchAndCheckout(repository, Model.Number, x));
                break;

            case CheckoutMode.Switch:
                operation = pullRequestsService.SwitchToBranch(repository, Model);
                break;

            case CheckoutMode.InvalidState:
                operation = pullRequestsService
                            .UnmarkLocalBranch(repository)
                            .SelectMany(_ => pullRequestsService.GetDefaultLocalBranchName(repository, Model.Number, Model.Title))
                            .SelectMany(x => pullRequestsService.FetchAndCheckout(repository, Model.Number, x));
                break;

            default:
                Debug.Fail("Invalid CheckoutMode in PullRequestDetailViewModel.DoCheckout.");
                operation = Observable.Empty <Unit>();
                break;
            }

            return(operation.Catch <Unit, Exception>(ex =>
            {
                CheckoutError = ex.Message;
                return Observable.Empty <Unit>();
            }));
        }