public void GetRepository_returns_expected_GitRepository_for_local_paths(string remoteUrl) { using var sut = GitRepositoryFactory.GetRepository(remoteUrl); sut.Kind.Should().Be(RepositoryKind.Local); sut.Should().BeAssignableTo <LocalGitRepository>(); }
public void GetRepository_returns_expected_GitRepository_for_remote_urls(string remoteUrl) { using var sut = GitRepositoryFactory.GetRepository(remoteUrl); sut.Kind.Should().Be(RepositoryKind.Remote); sut.Should().BeAssignableTo <RemoteGitRepository>(); }
protected override async Task <IEnumerable <IDocument> > ExecuteContextAsync(IExecutionContext context) { m_RepositoryUrl.EnsureNonDocument(); var repositoryUrl = await m_RepositoryUrl.GetValueAsync(null, context); // load repository using var repository = GitRepositoryFactory.GetRepository(repositoryUrl); var matchingBranches = GetMatchingBranches(context, repository); var matchingTags = GetMatchingTags(context, repository); if (!matchingBranches.Any() && !matchingTags.Any()) { context.LogWarning("No branches or tags found that match any of the specified tag or branch names"); return(Enumerable.Empty <IDocument>()); } var outputs = new List <IDocument>(); // for each branch, read documents and add them to the output. foreach (var branchName in matchingBranches) { var commitId = repository.GetHeadCommitId(branchName); var rootDir = repository.GetRootDirectory(commitId); var branchOutputs = Globber .GetFiles(rootDir, m_FilePatterns) .Select(file => ReadFile( context: context, repository: repository, file: file, branchName: branchName, tagName: null) ); outputs.AddRange(branchOutputs); } // for each tag, read documents and add them to the output. foreach (var tag in matchingTags) { var rootDir = repository.GetRootDirectory(tag.Commit); var tagOutputs = Globber .GetFiles(rootDir, m_FilePatterns) .Select(file => ReadFile( context: context, repository: repository, file: file, branchName: null, tagName: tag.Name) ); outputs.AddRange(tagOutputs); } return(outputs); }
public void Init(ProjectModel projectModel, GitRepositoryFactory factory) { _projectModel = projectModel; ProjectRootDir = _projectModel.ProjectRootDir; Type = (ProjectType)_projectModel.ProjectType; LiveRootDir = _projectModel.LiveRootDir; ProjectPublishedDir = Path.Combine(ProjectRootDir, "publish"); _gitRepository = factory.GetRepository(ProjectRootDir); _projectBuilder = ProjectBuilderFactory.GetBuilder(Type); _logger.LogInformation($"LiveRootDir = {LiveRootDir}, ProjectRootDir = {ProjectRootDir}, ProjectPublishedDir = {ProjectPublishedDir}"); }
public void GetRepository_throws_ArgumentException_for_unsupported_remote_urls(string remoteUrl) { Action act = () => GitRepositoryFactory.GetRepository(remoteUrl); act.Should().Throw <ArgumentException>(); }