Search in sources :

Example 1 with Revision

use of com.thoughtworks.go.domain.materials.Revision in project gocd by gocd.

the class LegacyMaterialCheckerTest method shouldGetModificationsSinceRevision.

@Test
public void shouldGetModificationsSinceRevision() {
    Material material = mock(Material.class);
    MaterialRevision materialRevision = mock(MaterialRevision.class);
    Revision revision = mock(Revision.class);
    List<Modification> modifications = new ArrayList<>();
    when(materialRevision.getRevision()).thenReturn(revision);
    when(materialService.modificationsSince(material, file, revision, null)).thenReturn(modifications);
    List<Modification> actual = checker.findModificationsSince(file, material, materialRevision);
    assertThat(actual, is(modifications));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Revision(com.thoughtworks.go.domain.materials.Revision) ArrayList(java.util.ArrayList) Material(com.thoughtworks.go.domain.materials.Material) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 2 with Revision

use of com.thoughtworks.go.domain.materials.Revision in project gocd by gocd.

the class BuildCause method materials.

public Materials materials() {
    final List<Material> materials = new ArrayList<>();
    materialRevisions.accept(new ModificationVisitorAdapter() {

        public void visit(Material material, Revision revision) {
            materials.add(material);
        }
    });
    return new Materials(materials);
}
Also used : MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Revision(com.thoughtworks.go.domain.materials.Revision) Materials(com.thoughtworks.go.config.materials.Materials) ArrayList(java.util.ArrayList) Material(com.thoughtworks.go.domain.materials.Material) ModificationVisitorAdapter(com.thoughtworks.go.domain.ModificationVisitorAdapter)

Example 3 with Revision

use of com.thoughtworks.go.domain.materials.Revision in project gocd by gocd.

the class ConfigMaterialUpdater method onMessage.

@Override
public void onMessage(MaterialUpdateCompletedMessage message) {
    Material material = message.getMaterial();
    // but MUS is still waiting for material updated message on MaterialUpdateCompletedTopic
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(format("[Config Material Update] Config material update completed for material %s. Starting parse process", material));
    }
    try {
        if (message instanceof MaterialUpdateFailedMessage) {
            MaterialUpdateFailedMessage failure = (MaterialUpdateFailedMessage) message;
            LOGGER.warn(String.format("[Config Material Update] Cannot update configuration part because material update has failed. Reason: %s", failure.getReason()));
        } else {
            File folder = materialRepository.folderFor(material);
            MaterialRevisions latestModification = materialRepository.findLatestModification(material);
            Revision revision = latestModification.firstModifiedMaterialRevision().getRevision();
            MaterialRevision lastParseRevision = getMaterialRevisionAtLastParseAttempt(message);
            if (lastParseRevision == null) {
                //never parsed
                updateConfigurationFromCheckout(folder, revision, material);
            } else if (latestModification.findRevisionFor(material.config()).hasChangedSince(lastParseRevision)) {
                // revision has changed. the config files might have been updated
                updateConfigurationFromCheckout(folder, revision, material);
            } else {
            // revision is the same as last time, no need to parse again
            }
        }
    } finally {
        // always post the original message further
        // this will remove material from inProgress in MUS
        topic.post(message);
    }
}
Also used : MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Revision(com.thoughtworks.go.domain.materials.Revision) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File)

Example 4 with Revision

use of com.thoughtworks.go.domain.materials.Revision in project gocd by gocd.

the class GitMaterialUpdater method updateTo.

public BuildCommand updateTo(String baseDir, RevisionContext revisionContext) {
    Revision revision = revisionContext.getLatestRevision();
    String workingDir = material.workingdir(new File(baseDir)).getPath();
    UrlArgument url = material.getUrlArgument();
    return compose(echoWithPrefix("Start updating %s at revision %s from %s", material.updatingTarget(), revision.getRevision(), url.forDisplay()), secret(url.forCommandline(), url.forDisplay()), cloneIfNeeded(workingDir, revisionContext.numberOfModifications() + 1), fetchRemote(workingDir), unshallowIfNeeded(workingDir, revision, new Integer[] { GitMaterial.UNSHALLOW_TRYOUT_STEP, Integer.MAX_VALUE }), resetWorkingCopy(workingDir, revision), echoWithPrefix("Done.\n"));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) Revision(com.thoughtworks.go.domain.materials.Revision) File(java.io.File)

Example 5 with Revision

use of com.thoughtworks.go.domain.materials.Revision in project gocd by gocd.

the class PipelineInstanceModel method hasNewRevisions.

public boolean hasNewRevisions(MaterialConfig materialConfig) {
    Revision currentRevision = getCurrentRevision(materialConfig);
    Revision revision = getLatestRevision(materialConfig);
    return !currentRevision.equals(revision);
}
Also used : Revision(com.thoughtworks.go.domain.materials.Revision)

Aggregations

Revision (com.thoughtworks.go.domain.materials.Revision)6 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)3 Material (com.thoughtworks.go.domain.materials.Material)3 File (java.io.File)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Materials (com.thoughtworks.go.config.materials.Materials)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 ModificationVisitorAdapter (com.thoughtworks.go.domain.ModificationVisitorAdapter)1 Modification (com.thoughtworks.go.domain.materials.Modification)1 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)1 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)1