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