IObservable <Unit> DoCheckout() { OperationError = null; return(Observable.Defer(async() => { var localBranches = await pullRequestsService.GetLocalBranches(LocalRepository, Model).ToList(); if (localBranches.Count > 0) { return pullRequestsService.SwitchToBranch(LocalRepository, Model); } else { return pullRequestsService .GetDefaultLocalBranchName(LocalRepository, Model.Number, Model.Title) .SelectMany(x => pullRequestsService.Checkout(LocalRepository, Model, x)); } }).Do(_ => { if (IsFromFork) { usageTracker.IncrementCounter(x => x.NumberOfForkPullRequestsCheckedOut).Forget(); } else { usageTracker.IncrementCounter(x => x.NumberOfLocalPullRequestsCheckedOut).Forget(); } })); }