Search in sources :

Example 96 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class MaterialChecker method findLatestRevisions.

public MaterialRevisions findLatestRevisions(MaterialRevisions peggedRevisions, Materials materials) {
    MaterialRevisions revisions = new MaterialRevisions();
    for (Material material : materials) {
        if (ensureHasRevisionForMaterial(peggedRevisions, revisions, material)) {
            continue;
        }
        for (MaterialRevision revision : materialRepository.findLatestModification(material)) {
            revision.markAsChanged();
            revisions.addRevision(revision);
        }
    }
    return revisions;
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 97 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class MaterialChecker method findRevisionsSince.

public MaterialRevisions findRevisionsSince(MaterialRevisions peggedRevisions, Materials newMaterials, MaterialRevisions previous, MaterialRevisions latestRevisions) {
    MaterialRevisions materialRevisions = new MaterialRevisions();
    for (Material material : newMaterials) {
        MaterialRevision previousRevision = previous.findRevisionFor(material);
        if (previousRevision == null) {
            materialRevisions.addRevision(latestRevisions.findRevisionFor(material));
        } else {
            Material previousMaterial = previousRevision.getMaterial();
            if (ensureHasRevisionForMaterial(peggedRevisions, materialRevisions, previousMaterial)) {
                continue;
            }
            previousMaterial = previousMaterial instanceof ScmMaterial ? newMaterials.byFolder(previousMaterial.getFolder()) : previousMaterial;
            List<Modification> newModifications = materialRepository.findModificationsSince(previousMaterial, previousRevision);
            MaterialRevision newMaterialRevision = previousRevision.latestChanges(material, previousRevision.getModifications(), newModifications);
            materialRevisions.addRevision(newMaterialRevision);
        }
    }
    return materialRevisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Material(com.thoughtworks.go.domain.materials.Material) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 98 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class ScmMaterialUpdater method addNewMaterialWithModifications.

public void addNewMaterialWithModifications(Material material, File folder) {
    MaterialRevisions materialRevisions = materialRepository.findLatestModification(material);
    Modifications list = materialRevisions.getModifications(material);
    insertLatestOrNewModifications(material, materialRepository.findOrCreateFrom(material), folder, list);
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions)

Example 99 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class SpecificMaterialRevisionFactory method create.

public MaterialRevisions create(String pipelineName, Map<String, String> revisionInfo) {
    MaterialRevisions materialRevisions = new MaterialRevisions();
    for (String materialFingerprint : revisionInfo.keySet()) {
        MaterialConfig materialConfig = goConfigService.findMaterial(new CaseInsensitiveString(pipelineName), materialFingerprint);
        if (materialConfig == null) {
            throw new RuntimeException(String.format("Material with fingerprint [%s] for pipeline [%s] does not exist", materialFingerprint, pipelineName));
        }
        materialRevisions.addRevision(materialChecker.findSpecificRevision(materialConfigConverter.toMaterial(materialConfig), revisionInfo.get(materialFingerprint)));
    }
    return materialRevisions;
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 100 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class AutoBuildCauseTest method shouldSetApproverToCruiseForTheProducedBuildCause.

@Test
public void shouldSetApproverToCruiseForTheProducedBuildCause() throws Exception {
    SvnMaterial material = new SvnMaterial("http://foo.bar/baz", "user", "pass", false);
    MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(material, new Modification(new Date(), "1234", "MOCK_LABEL-12", null)));
    when(goConfigService.upstreamDependencyGraphOf("foo", cruiseConfig)).thenReturn(new PipelineConfigDependencyGraph(null));
    when(pipelineService.getRevisionsBasedOnDependencies(materialRevisions, cruiseConfig, new CaseInsensitiveString("foo"))).thenReturn(materialRevisions);
    BuildCause buildCause = new AutoBuild(goConfigService, pipelineService, "foo", new SystemEnvironment(), materialChecker, serverHealthService).onModifications(materialRevisions, false, null);
    assertThat(buildCause.getApprover(), is(GoConstants.DEFAULT_APPROVED_BY));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Modification(com.thoughtworks.go.domain.materials.Modification) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Aggregations

MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)215 Test (org.junit.Test)172 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)110 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)72 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)55 Date (java.util.Date)52 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)46 Modification (com.thoughtworks.go.domain.materials.Modification)41 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)35 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)31 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)30 Materials (com.thoughtworks.go.config.materials.Materials)24 Pipeline (com.thoughtworks.go.domain.Pipeline)22 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 Material (com.thoughtworks.go.domain.materials.Material)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)15 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)12 File (java.io.File)12