Search in sources :

Example 11 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldSupportSubmoduleFolderInGitMaterials.

@Test
public void shouldSupportSubmoduleFolderInGitMaterials() throws Exception {
    Materials materials = MaterialsMother.gitMaterials("gitUrl", "submoduleFolder", null);
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(materials.convertToConfigs());
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    assertNotInserted(pipeline.getId());
    save(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    Materials materialsFromDB = pipelineFromDB.getMaterials();
    GitMaterial gitMaterial = (GitMaterial) materialsFromDB.get(0);
    assertThat(gitMaterial.getSubmoduleFolder(), is("submoduleFolder"));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 12 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class Materials method latestModification.

/**
 * @deprecated Used only in tests
 */
public MaterialRevisions latestModification(File baseDir, final SubprocessExecutionContext execCtx) {
    MaterialRevisions revisions = new MaterialRevisions();
    for (Material material : this) {
        List<Modification> modifications = new ArrayList<>();
        if (material instanceof SvnMaterial) {
            modifications = ((SvnMaterial) material).latestModification(baseDir, execCtx);
        }
        if (material instanceof HgMaterial) {
            modifications = ((HgMaterial) material).latestModification(baseDir, execCtx);
        }
        if (material instanceof GitMaterial) {
            modifications = ((GitMaterial) material).latestModification(baseDir, execCtx);
        }
        if (material instanceof P4Material) {
            modifications = ((P4Material) material).latestModification(baseDir, execCtx);
        }
        if (material instanceof TfsMaterial) {
            modifications = ((TfsMaterial) material).latestModification(baseDir, execCtx);
        }
        if (material instanceof DependencyMaterial) {
            modifications = ((DependencyMaterial) material).latestModification(baseDir, execCtx);
        }
        revisions.addRevision(material, modifications);
    }
    return revisions;
}
Also used : TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) ArrayList(java.util.ArrayList) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material)

Example 13 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class MaterialsTest method shouldNotRemoveJunkFoldersWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsTrue.

@Test
public void shouldNotRemoveJunkFoldersWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsTrue() throws Exception {
    File junkFolder = temporaryFolder.newFolder("junk-folder");
    Materials materials = new Materials();
    GitMaterial gitMaterial = new GitMaterial("http://some-url.com", "some-branch");
    materials.add(gitMaterial);
    materials.cleanUp(temporaryFolder.getRoot(), mock(ConsoleOutputStreamConsumer.class));
    assertThat(junkFolder.exists(), is(true));
    temporaryFolder.delete();
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) ConsoleOutputStreamConsumer(com.thoughtworks.go.util.command.ConsoleOutputStreamConsumer) File(java.io.File) Test(org.junit.Test)

Example 14 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class MaterialsTest method shouldRemoveJunkFoldersWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsFalse.

@Test
public void shouldRemoveJunkFoldersWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsFalse() throws Exception {
    File junkFolder = temporaryFolder.newFolder("junk-folder");
    Materials materials = new Materials();
    GitMaterial gitMaterial = new GitMaterial("http://some-url.com", "some-branch", "some-folder");
    materials.add(gitMaterial);
    materials.cleanUp(temporaryFolder.getRoot(), mock(ConsoleOutputStreamConsumer.class));
    assertThat(junkFolder.exists(), is(false));
    temporaryFolder.delete();
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) ConsoleOutputStreamConsumer(com.thoughtworks.go.util.command.ConsoleOutputStreamConsumer) File(java.io.File) Test(org.junit.Test)

Example 15 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class MaterialsMother method gitMaterial.

public static GitMaterial gitMaterial(String url, String submoduleFolder, String branch) {
    GitMaterial gitMaterial = new GitMaterial(url, branch);
    gitMaterial.setSubmoduleFolder(submoduleFolder);
    return gitMaterial;
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial)

Aggregations

GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)146 Test (org.junit.Test)137 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)70 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)55 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)31 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)20 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)13 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 Modification (com.thoughtworks.go.domain.materials.Modification)11 File (java.io.File)11 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)10 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)10 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)10 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)10 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)9 Material (com.thoughtworks.go.domain.materials.Material)8 Materials (com.thoughtworks.go.config.materials.Materials)7