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 TimedBuildTest method shouldReturnEmptyBuildCauseIfThereIsNoModification_whenTriggeringOnlyForMaterialChange.
@Test
public void shouldReturnEmptyBuildCauseIfThereIsNoModification_whenTriggeringOnlyForMaterialChange() throws Exception {
MaterialRevisions someRevisions = new MaterialRevisions(new MaterialRevision(MaterialsMother.gitMaterial("git://url"), ModificationsMother.aCheckIn("1", "file1.txt")));
BuildType timedBuild = new TimedBuild();
PipelineConfig timerConfig = PipelineConfigMother.pipelineConfigWithTimer("Timer", "* * * * * ?", true);
BuildCause buildCause = timedBuild.onEmptyModifications(timerConfig, someRevisions);
assertThat(buildCause, is(nullValue()));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class ViewCacheKeyTest method shouldGenerateKeyForEnvironmentPipelineFragment.
@Test
public void shouldGenerateKeyForEnvironmentPipelineFragment() {
MaterialRevisions materialRevisions = ModificationsMother.createHgMaterialRevisions();
Modification latestModification = materialRevisions.getMaterialRevision(0).getModifications().remove(0);
PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused()).updateAdministrability(true);
StageInstanceModels stages = new StageInstanceModels();
stages.add(stageInstance("stageName", 13, JobState.Building, JobResult.Unknown));
stages.add(new NullStageHistoryItem("stage2", true));
PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createWithModifications(materialRevisions, "someone"), stages);
pipelineInstance.setMaterialConfigs(materialRevisions.getMaterials().convertToConfigs());
pipelineInstance.setLatestRevisions(new MaterialRevisions(new MaterialRevision(materialRevisions.getMaterialRevision(0).getMaterial(), latestModification)));
pipelineInstance.setId(12);
model.addPipelineInstance(pipelineInstance);
assertThat(model.hasNewRevisions(), is(true));
assertThat(viewCacheKey.forEnvironmentPipelineBox(model), is("view_environmentPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||true|true"));
model.updateAdministrability(false);
assertThat(viewCacheKey.forEnvironmentPipelineBox(model), is("view_environmentPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||false|true"));
}
use of com.thoughtworks.go.domain.MaterialRevisions 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;
}
Aggregations