Search in sources :

Example 71 with Modification

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

the class SvnLogXmlParserTest method shouldParseBJCruiseLogCorrectly.

@Test
public void shouldParseBJCruiseLogCorrectly() {
    String firstChangeLog = "<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + "   revision=\"11238\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:16.598195Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "<path\n" + "   action=\"M\">/trunk/test/functional/cards_controller_quick_add_test.rb</path>\n" + "<path\n" + "   action=\"M\">/trunk/app/controllers/cards_controller.rb</path>\n" + "</paths>\n" + "<msg>#2761, fix random test failure and add quick add card type to session</msg>\n" + "</logentry>\n" + "</log>";
    String secondChangeLog = "<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + "   revision=\"11239\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:36.209014Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "</paths>\n" + "<msg>still fix test</msg>\n" + "</logentry>\n" + "<logentry\n" + "   revision=\"11240\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:47.614448Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "</paths>\n" + "<msg>fix test remove messaging helper</msg>\n" + "</logentry>\n" + "</log>";
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> mods = parser.parse(firstChangeLog, ".", new SAXBuilder());
    assertThat(mods.get(0).getUserName(), is("yxchu"));
    List<Modification> mods2 = parser.parse(secondChangeLog, ".", new SAXBuilder());
    assertThat(mods2.size(), is(2));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 72 with Modification

use of com.thoughtworks.go.domain.materials.Modification 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 73 with Modification

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

the class FanInGraph method createFinalRevisionsForDepChildren.

private List<MaterialRevision> createFinalRevisionsForDepChildren(List<DependencyFanInNode> depChildren) {
    List<MaterialRevision> finalRevisions = new ArrayList<>();
    for (DependencyFanInNode child : depChildren) {
        final List<Modification> modifications = materialRepository.modificationFor(child.currentRevision);
        if (modifications.isEmpty()) {
            throw new NoModificationsPresentForDependentMaterialException(child.currentRevision.stageLocator());
        }
        finalRevisions.add(new MaterialRevision(materialConfigConverter.toMaterial(child.materialConfig), modifications));
    }
    return finalRevisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) NoModificationsPresentForDependentMaterialException(com.thoughtworks.go.server.service.NoModificationsPresentForDependentMaterialException) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 74 with Modification

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

the class CcTrayBreakersCalculatorTest method shouldCaptureUniqueModificationAuthorNamesAsBreakers_inCaseOfFailure.

@Test
public void shouldCaptureUniqueModificationAuthorNamesAsBreakers_inCaseOfFailure() throws Exception {
    Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
    Modification user2Commit = ModificationsMother.checkinWithComment("124", "comment 2", "user2", "user2@domain2.com", new Date(), "bar.c");
    Modification otherCommitOfUser1 = ModificationsMother.checkinWithComment("125", "comment 3", "user1", "user1@different-email.com", new Date(), "baz.c");
    MaterialRevision revision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit, user2Commit, otherCommitOfUser1);
    revision.markAsChanged();
    when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(new MaterialRevisions(revision));
    CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
    Set<String> actualBreakers = status.calculateFor(failedStage());
    assertThat(actualBreakers, is(s("user1", "user2")));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 75 with Modification

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

the class CcTrayBreakersCalculatorTest method shouldCaptureAuthorNamesOfChangedRevisionsOnlyAsBreakers.

@Test
public void shouldCaptureAuthorNamesOfChangedRevisionsOnlyAsBreakers() throws Exception {
    Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
    Modification user2Commit = ModificationsMother.checkinWithComment("124", "comment 2", "user2", "user2@domain2.com", new Date(), "bar.c");
    MaterialRevision changedRevision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit, user2Commit);
    changedRevision.markAsChanged();
    Modification user3CommitForUnchangedRevision = ModificationsMother.checkinWithComment("125", "comment 1", "user3", "user3@domain2.com", new Date(), "bar.c");
    MaterialRevision unchangedRevision = new MaterialRevision(MaterialsMother.gitMaterial("bar.com"), user3CommitForUnchangedRevision);
    MaterialRevisions revisions = new MaterialRevisions(changedRevision, unchangedRevision);
    when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(revisions);
    CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
    Set<String> actualBreakers = status.calculateFor(failedStage());
    assertThat(actualBreakers, is(s("user1", "user2")));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Modification (com.thoughtworks.go.domain.materials.Modification)246 Test (org.junit.Test)176 Date (java.util.Date)76 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)65 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)54 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)40 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)38 ArrayList (java.util.ArrayList)35 File (java.io.File)25 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)21 Modifications (com.thoughtworks.go.domain.materials.Modifications)21 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 Material (com.thoughtworks.go.domain.materials.Material)20 Username (com.thoughtworks.go.server.domain.Username)17 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)16 HashMap (java.util.HashMap)16 StringContains.containsString (org.hamcrest.core.StringContains.containsString)15 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)14 Stage (com.thoughtworks.go.domain.Stage)13 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)13