Search in sources :

Example 16 with MaterialRevisions

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));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 17 with MaterialRevisions

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"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 18 with MaterialRevisions

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;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 19 with MaterialRevisions

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));
    }
}
Also used : User(com.thoughtworks.go.domain.User) SendEmailMessage(com.thoughtworks.go.server.messaging.SendEmailMessage) TestSuite(com.thoughtworks.go.domain.testinfo.TestSuite) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Stage(com.thoughtworks.go.domain.Stage) Users(com.thoughtworks.go.domain.Users) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline)

Example 20 with MaterialRevisions

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));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Test(org.junit.Test)

Aggregations

MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)215 Test (org.junit.Test)172 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)110 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)72 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)55 Date (java.util.Date)52 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)46 Modification (com.thoughtworks.go.domain.materials.Modification)41 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)35 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)31 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)30 Materials (com.thoughtworks.go.config.materials.Materials)24 Pipeline (com.thoughtworks.go.domain.Pipeline)22 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 Material (com.thoughtworks.go.domain.materials.Material)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)15 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)12 File (java.io.File)12