/// <inheridoc/> public override async Task <SourceCodeRepository> Add(SourceCodeRepository sourceCodeRepository) { //if fork not requested, look up the repo id if (!sourceCodeRepository.Fork) { var gitRepo = await _gitClient.LoadGitRepositoryIfExists(sourceCodeRepository.SourceRepositoryName); if (gitRepo == null) { throw new ArgumentException( $"Repository {sourceCodeRepository.SourceRepositoryName} does not exist", nameof(SourceCodeRepository)); } sourceCodeRepository.UpdateWithVstsRepo(gitRepo.Id); return(sourceCodeRepository); } //otherwise fork to a new repo var repo = await _gitClient.CreateForkIfNotExists(_vstsConfiguration.VstsCollectionId, _vstsConfiguration.VstsTargetProjectId, sourceCodeRepository); if (!repo.IsFork) { _bigBrother.Publish(new ForkRequestFailed { ForkName = repo.Name, Message = $"Repository already exists but is not a fork" }); } else { sourceCodeRepository.UpdateWithVstsRepo(repo.Id); _bigBrother.Publish(new ForkRequestSucceeded { ForkName = repo.Name }); return(sourceCodeRepository); } return(null); }