Search in sources :

Example 86 with GitMaterial

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

the class MaterialsTest method shouldGenerateNoopCommandWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsTrue.

@Test
public void shouldGenerateNoopCommandWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsTrue() throws Exception {
    Materials materials = new Materials();
    materials.add(new GitMaterial("http://some-url.com", "some-branch"));
    assertThat(materials.cleanUpCommand("foo"), is(BuildCommand.noop()));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Test(org.junit.Test)

Example 87 with GitMaterial

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

the class MaterialsTest method shouldReturnExistingGitMaterialFromMaterialsIfItContainsOne.

@Test
public void shouldReturnExistingGitMaterialFromMaterialsIfItContainsOne() {
    Materials materials = new Materials();
    GitMaterial existingMaterial = new GitMaterial("foo");
    materials.add(existingMaterial);
    assertThat(materials.getGitMaterial(), is(sameInstance(existingMaterial)));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Test(org.junit.Test)

Example 88 with GitMaterial

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

the class MaterialRevisions method updateToCommand.

public BuildCommand updateToCommand(String baseDir) {
    List<BuildCommand> commands = new ArrayList<>();
    for (MaterialRevision revision : revisions) {
        Material material = revision.getMaterial();
        if (material instanceof ScmMaterial) {
            if (material instanceof GitMaterial) {
                GitMaterialUpdater updater = new GitMaterialUpdater((GitMaterial) material);
                commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
            } else if (material instanceof HgMaterial) {
                HgMaterialUpdater updater = new HgMaterialUpdater((HgMaterial) material);
                commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
            } else if (material instanceof SvnMaterial) {
                SvnMaterialUpdater updater = new SvnMaterialUpdater((SvnMaterial) material);
                commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
            } else if (material instanceof PackageMaterial) {
            // do nothing
            } else if (material instanceof TfsMaterial) {
                TfsMaterialUpdater updater = new TfsMaterialUpdater((TfsMaterial) material);
                commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
            } else if (material instanceof P4Material) {
                P4MaterialUpdater updater = new P4MaterialUpdater((P4Material) material);
                commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
            } else {
                commands.add(BuildCommand.fail("%s Material is not supported for new build command agent", material.getTypeForDisplay()));
            }
        }
    }
    return BuildCommand.compose(commands);
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) P4MaterialUpdater(com.thoughtworks.go.domain.materials.perforce.P4MaterialUpdater) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) 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) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) GitMaterialUpdater(com.thoughtworks.go.domain.materials.git.GitMaterialUpdater) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) SvnMaterialUpdater(com.thoughtworks.go.domain.materials.svn.SvnMaterialUpdater) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) HgMaterialUpdater(com.thoughtworks.go.domain.materials.mercurial.HgMaterialUpdater) TfsMaterialUpdater(com.thoughtworks.go.domain.materials.tfs.TfsMaterialUpdater) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)

Example 89 with GitMaterial

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

the class MaterialsTest method shouldGenerateCleanupCommandForRemovingJunkFoldersWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsFalse.

@Test
public void shouldGenerateCleanupCommandForRemovingJunkFoldersWhenCleanUpIsCalled_hasOneMaterialUseBaseFolderReturnsFalse() throws Exception {
    Materials materials = new Materials();
    GitMaterial gitMaterial = new GitMaterial("http://some-url.com", "some-branch", "some-folder");
    materials.add(gitMaterial);
    BuildCommand command = materials.cleanUpCommand("basedir");
    assertThat(command.getName(), is("cleandir"));
    assertThat(command.getStringArg("path"), is("basedir"));
    assertThat(command.getArrayArg("allowed"), is(new String[] { "some-folder", "cruise-output" }));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCommand(com.thoughtworks.go.domain.BuildCommand) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 90 with GitMaterial

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

the class GitTestRepo method createMaterial.

public GitMaterial createMaterial(String dest) {
    GitMaterial gitMaterial = new GitMaterial(this.projectRepositoryUrl());
    gitMaterial.setFolder(dest);
    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