use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class SvnExternalTest method shouldGetLatestRevision.
@Test
public void shouldGetLatestRevision() {
SvnMaterial svn = svnMaterial(svnRepo.projectRepositoryUrl(), null);
SvnMaterial svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
final Materials materials = new Materials(svn, svnExt);
final MaterialRevisions materialRevisions = materials.latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
assertThat(materialRevisions.numberOfRevisions(), is(2));
MaterialRevision main = materialRevisions.getRevisions().get(0);
assertThat(main.getMaterial(), is(svn));
assertThat(main.getModifications().size(), is(1));
assertThat(main.getRevision().getRevision(), is("5"));
MaterialRevision external = materialRevisions.getRevisions().get(1);
assertThat(external.getMaterial(), is(svnExt));
assertThat(external.getRevision().getRevision(), is("4"));
assertThat(external.getModifications().size(), is(1));
}
use of com.thoughtworks.go.domain.MaterialRevisions 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.MaterialRevisions 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.MaterialRevisions in project gocd by gocd.
the class StageNotificationService method sendNotifications.
public void sendNotifications(StageIdentifier stageIdentifier, StageEvent event, Username cancelledBy) {
Users users = userService.findValidSubscribers(stageIdentifier.stageConfigIdentifier());
if (users.isEmpty()) {
return;
}
Stage stage = stageService.findStageWithIdentifier(stageIdentifier);
Pipeline pipeline = pipelineService.fullPipelineById(stage.getPipelineId());
MaterialRevisions materialRevisions = pipeline.getMaterialRevisions();
List<TestSuite> failedTestSuites = null;
if (systemEnvironment.isShineEnabled()) {
failedTestSuites = shineDao.failedTestsFor(stageIdentifier);
}
String emailBody = new EmailBodyGenerator(materialRevisions, cancelledBy, systemEnvironment, stageIdentifier, failedTestSuites).getContent();
String subject = "Stage [" + stageIdentifier.stageLocator() + "]" + event.describe();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("Processing notification titled [%s]", subject));
}
for (User user : users) {
if (user.matchNotification(stageIdentifier.stageConfigIdentifier(), event, materialRevisions)) {
StringBuilder emailWithSignature = new StringBuilder(emailBody).append("\n\n").append("Sent by Go on behalf of ").append(user.getName());
SendEmailMessage sendEmailMessage = new SendEmailMessage(subject, emailWithSignature.toString(), user.getEmail());
emailNotificationTopic.post(sendEmailMessage);
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("Finished processing notification titled [%s]", subject));
}
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class MaterialDatabaseGitWithSubmodulesUpdaterTest method shouldUpdateModificationsForExternalsAsWell.
@Test
public void shouldUpdateModificationsForExternalsAsWell() throws Exception {
updater.updateMaterial(material);
MaterialRevisions materialRevisions = materialRepository.findLatestModification(material);
assertThat(materialRevisions.numberOfRevisions(), is(1));
}
Aggregations