Search in sources :

Example 21 with GitSubmoduleRepos

use of com.thoughtworks.go.helper.GitSubmoduleRepos in project gocd by gocd.

the class GitMaterialTest method shouldGetLatestModificationsFromRepoWithSubmodules.

@Test
public void shouldGetLatestModificationsFromRepoWithSubmodules() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
    submoduleRepos.addSubmodule(SUBMODULE, "sub1");
    GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
    File workingDirectory = TestFileUtil.createTempFolder("workingDir-" + System.currentTimeMillis());
    Materials materials = new Materials();
    materials.add(gitMaterial);
    MaterialRevisions materialRevisions = materials.latestModification(workingDirectory, new TestSubprocessExecutionContext());
    assertThat(materialRevisions.numberOfRevisions(), is(1));
    MaterialRevision materialRevision = materialRevisions.getMaterialRevision(0);
    assertThat(materialRevision.getRevision().getRevision(), is(submoduleRepos.currentRevision(GitSubmoduleRepos.NAME)));
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 22 with GitSubmoduleRepos

use of com.thoughtworks.go.helper.GitSubmoduleRepos in project gocd by gocd.

the class GitMaterialTest method shouldUpdateSubmodules.

@Test
public void shouldUpdateSubmodules() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
    submoduleRepos.addSubmodule(SUBMODULE, "sub1");
    GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
    File serverWorkingDir = TestFileUtil.createTempFolder("workingDir-" + System.currentTimeMillis());
    Materials materials = new Materials();
    materials.add(gitMaterial);
    MaterialRevisions materialRevisions = materials.latestModification(serverWorkingDir, new TestSubprocessExecutionContext());
    File agentWorkingDir = TestFileUtil.createTempFolder("workingDir-" + System.currentTimeMillis());
    MaterialRevision materialRevision = materialRevisions.getMaterialRevision(0);
    materialRevision.updateTo(agentWorkingDir, inMemoryConsumer(), new TestSubprocessExecutionContext());
    File localFile = submoduleRepos.files(GitSubmoduleRepos.NAME).get(0);
    assertThat(new File(agentWorkingDir, localFile.getName()), exists());
    File file = submoduleRepos.files(SUBMODULE).get(0);
    File workingSubmoduleFolder = new File(agentWorkingDir, "sub1");
    assertThat(new File(workingSubmoduleFolder, file.getName()), exists());
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Aggregations

GitSubmoduleRepos (com.thoughtworks.go.helper.GitSubmoduleRepos)22 File (java.io.File)13 Test (org.junit.Test)12 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)11 StringContains.containsString (org.hamcrest.core.StringContains.containsString)7 RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)6 RandomAccessFile (java.io.RandomAccessFile)5 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)4 RegexMatcher (com.thoughtworks.go.matchers.RegexMatcher)4 Materials (com.thoughtworks.go.config.materials.Materials)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 Modification (com.thoughtworks.go.domain.materials.Modification)2 Matcher (java.util.regex.Matcher)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)1 SysOutStreamConsumer (com.thoughtworks.go.mail.SysOutStreamConsumer)1 IOException (java.io.IOException)1 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)1