use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class SvnExternalTest method shouldGetLatestRevisionFromExpandedSvnExternalRepository.
@Test
public void shouldGetLatestRevisionFromExpandedSvnExternalRepository() {
MaterialRevisions materialRevisions = new MaterialRevisions();
Material svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
List<Modification> modifications = ((SvnMaterial) svnExt).latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
materialRevisions.addRevision(svnExt, modifications);
assertThat(materialRevisions.numberOfRevisions(), is(1));
MaterialRevision materialRevision = materialRevisions.getRevisions().get(0);
assertThat(materialRevision.getMaterial(), is(svnExt));
assertThat(materialRevision.getRevision().getRevision(), is("4"));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class StageConverter method createBuildCause.
private ArrayList<StageNotificationDTO.MaterialRevisionDTO> createBuildCause(BuildCause buildCause) {
ArrayList<StageNotificationDTO.MaterialRevisionDTO> revisions = new ArrayList<>();
for (MaterialRevision currentRevision : buildCause.getMaterialRevisions()) {
Map<String, Object> attributes = currentRevision.getMaterial().getAttributes(false);
ArrayList<StageNotificationDTO.ModificationDTO> modifications = new ArrayList<>();
for (Modification modification : currentRevision.getModifications()) {
modifications.add(new StageNotificationDTO.ModificationDTO(modification.getRevision(), modification.getModifiedTime(), modification.getAdditionalDataMap()));
}
revisions.add(new StageNotificationDTO.MaterialRevisionDTO(attributes, currentRevision.isChanged(), modifications));
}
return revisions;
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class FanInGraph method createFinalRevisionsForScmChildren.
private List<MaterialRevision> createFinalRevisionsForScmChildren(PipelineTimelineEntry latestRootNodeInstance, List<RootFanInNode> scmChildren, List<DependencyFanInNode> depChildren) {
Set<FaninScmMaterial> scmMaterialsFromDepChildren = scmMaterialsOfDepChildren(depChildren);
List<MaterialRevision> finalRevisions = new ArrayList<>();
for (RootFanInNode child : scmChildren) {
child.setScmRevision(scmMaterialsFromDepChildren);
MaterialConfig materialConfig = child.materialConfig;
Material material = materialConfigConverter.toMaterial(materialConfig);
MaterialRevision revision = new MaterialRevision(material);
if (latestRootNodeInstance != null) {
PipelineInstanceModel pipeline = pipelineDao.findPipelineHistoryByNameAndCounter(latestRootNodeInstance.getPipelineName(), latestRootNodeInstance.getCounter());
for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) {
if (materialRevision.getMaterial().getFingerprint().equals(child.materialConfig.getFingerprint())) {
List<Modification> modificationsSince = materialRepository.findModificationsSinceAndUptil(material, materialRevision, child.scmRevision);
revision.addModifications(modificationsSince);
break;
}
}
}
if (revision.getModifications().isEmpty() && child.scmRevision == null) {
MaterialRevisions latestRevisions = materialRepository.findLatestRevisions(new MaterialConfigs(materialConfig));
finalRevisions.addAll(latestRevisions.getRevisions());
continue;
}
if (revision.getModifications().isEmpty()) {
revision = new MaterialRevision(material, materialRepository.findModificationWithRevision(material, child.scmRevision.revision));
}
finalRevisions.add(revision);
}
return finalRevisions;
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class FanInGraph method createFinalRevisionsForDepChildren.
private List<MaterialRevision> createFinalRevisionsForDepChildren(List<DependencyFanInNode> depChildren) {
List<MaterialRevision> finalRevisions = new ArrayList<>();
for (DependencyFanInNode child : depChildren) {
final List<Modification> modifications = materialRepository.modificationFor(child.currentRevision);
if (modifications.isEmpty()) {
throw new NoModificationsPresentForDependentMaterialException(child.currentRevision.stageLocator());
}
finalRevisions.add(new MaterialRevision(materialConfigConverter.toMaterial(child.materialConfig), modifications));
}
return finalRevisions;
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class MaterialDatabaseDependencyUpdaterTest method shouldReturnLatestPipelineIfThereHasBeenANewOne.
@Test
public void shouldReturnLatestPipelineIfThereHasBeenANewOne() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
stubStageServiceGetHistory(null, stages(9));
updater.updateMaterial(dependencyMaterial);
List<Modification> modification = materialRepository.findLatestModification(dependencyMaterial).getMaterialRevision(0).getModifications();
stubStageServiceGetHistoryAfter(null, 9, stages(10));
updater.updateMaterial(dependencyMaterial);
List<Modification> newModifications = materialRepository.findModificationsSince(dependencyMaterial, new MaterialRevision(dependencyMaterial, modification));
assertThat(newModifications.size(), is(1));
assertThat(newModifications.get(0).getRevision(), is("pipeline-name/10/stage-name/0"));
assertThat(newModifications.get(0).getPipelineLabel(), is("LABEL-10"));
}
Aggregations