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;
}
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;
}
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);
}
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;
}
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));
}
Aggregations