Search in sources :

Example 6 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 7 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 8 with 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()));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 9 with MaterialRevisions

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"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Example 10 with MaterialRevisions

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;
}
Also used : TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) ArrayList(java.util.ArrayList) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) 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) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material)

Aggregations

MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)212 Test (org.junit.Test)166 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)111 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)68 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)55 Date (java.util.Date)49 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)46 Modification (com.thoughtworks.go.domain.materials.Modification)38 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)33 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)31 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)31 Materials (com.thoughtworks.go.config.materials.Materials)27 Pipeline (com.thoughtworks.go.domain.Pipeline)20 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 Material (com.thoughtworks.go.domain.materials.Material)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)15 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)14 File (java.io.File)12