private async Task <ForkData> TryFindUserFork(string userName, ForkData originFork) { var userFork = await _collaborationPlatform.GetUserRepository(userName, originFork.Name); if (userFork != null) { var isMatchingFork = RepoIsForkOf(userFork, originFork.Uri); var forkIsPushable = userFork.UserPermissions.Push; if (isMatchingFork && forkIsPushable) { // the user has a pushable fork return(RepositoryToForkData(userFork)); } // the user has a repo of that name, but it can't be used. // Don't try to create it _logger.Normal($"User '{userName}' fork of '{originFork.Name}' exists but is unsuitable. Matching: {isMatchingFork}. Pushable: {forkIsPushable}"); return(null); } // no user fork exists, try and create it as a fork of the main repo var newFork = await _collaborationPlatform.MakeUserFork(originFork.Owner, originFork.Name); if (newFork != null) { return(RepositoryToForkData(newFork)); } return(null); }