Search in sources :

Example 6 with GitSubmoduleRepos

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

the class MaterialDatabaseGitWithSubmodulesUpdaterTest method repo.

protected TestRepo repo() throws Exception {
    GitSubmoduleRepos testRepoWithExternal = new GitSubmoduleRepos();
    testRepoWithExternal.addSubmodule("submodule-1", "sub1");
    return testRepoWithExternal;
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos)

Example 7 with GitSubmoduleRepos

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

the class MaterialExpansionServiceTest method shouldNotExpandGitSubmodulesIntoMultipleMaterialsWhenExpandingGitMaterialForScheduling.

@Test
public void shouldNotExpandGitSubmodulesIntoMultipleMaterialsWhenExpandingGitMaterialForScheduling() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
    submoduleRepos.addSubmodule("submodule-1", "sub1");
    GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
    when(materialConfigConverter.toMaterials(new MaterialConfigs(gitMaterial.config()))).thenReturn(new Materials(gitMaterial));
    Materials materials = new Materials();
    materialExpansionService.expandForScheduling(gitMaterial, materials);
    assertThat(materials.size(), is(1));
    assertThat(materials.get(0), is(gitMaterial));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 8 with GitSubmoduleRepos

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

the class GitMaterialTest method shouldHaveModificationsWhenSubmoduleIsRemoved.

@Test
public void shouldHaveModificationsWhenSubmoduleIsRemoved() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
    submoduleRepos.addSubmodule(SUBMODULE, "sub1");
    GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
    File serverWorkingDir = TestFileUtil.createTempFolder("workingDir-" + System.currentTimeMillis());
    List<Modification> beforeAdd = gitMaterial.latestModification(serverWorkingDir, new TestSubprocessExecutionContext());
    submoduleRepos.removeSubmodule("sub1");
    List<Modification> after = gitMaterial.modificationsSince(serverWorkingDir, new Modifications(beforeAdd).latestRevision(gitMaterial), new TestSubprocessExecutionContext());
    assertThat(after.size(), is(1));
    assertThat(after.get(0).getComment(), is("Removed submodule sub1"));
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 9 with GitSubmoduleRepos

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

the class GitMaterialTest method shouldHaveModificationsWhenSubmoduleIsAdded.

@Test
public void shouldHaveModificationsWhenSubmoduleIsAdded() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
    submoduleRepos.addSubmodule(SUBMODULE, "sub1");
    GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
    File serverWorkingDir = TestFileUtil.createTempFolder("workingDir-" + System.currentTimeMillis());
    List<Modification> beforeAdd = gitMaterial.latestModification(serverWorkingDir, new TestSubprocessExecutionContext());
    submoduleRepos.addSubmodule(SUBMODULE, "new-submodule");
    List<Modification> afterAdd = gitMaterial.modificationsSince(serverWorkingDir, new Modifications(beforeAdd).latestRevision(gitMaterial), new TestSubprocessExecutionContext());
    assertThat(afterAdd.size(), is(1));
    assertThat(afterAdd.get(0).getComment(), is("Added submodule new-submodule"));
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 10 with GitSubmoduleRepos

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

the class GitMaterialTest method shouldRemoveSubmoduleFolderFromWorkingDirWhenSubmoduleIsRemovedFromRepo.

@Test
public void shouldRemoveSubmoduleFolderFromWorkingDirWhenSubmoduleIsRemovedFromRepo() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
    submoduleRepos.addSubmodule(SUBMODULE, "sub1");
    GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
    StringRevision revision = new StringRevision("origin/master");
    gitMaterial.updateTo(outputStreamConsumer, workingDir, new RevisionContext(revision), new TestSubprocessExecutionContext());
    assertThat(new File(workingDir, "sub1"), exists());
    submoduleRepos.removeSubmodule("sub1");
    outputStreamConsumer = inMemoryConsumer();
    gitMaterial.updateTo(outputStreamConsumer, workingDir, new RevisionContext(revision), new TestSubprocessExecutionContext());
    assertThat(new File(workingDir, "sub1"), not(exists()));
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) 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