Search in sources :

Example 21 with IgnoredFiles

use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.

the class MaterialRevisionTest method shouldUseLatestMaterial.

@Test
public void shouldUseLatestMaterial() throws Exception {
    MaterialRevision original = new MaterialRevision(hgMaterial, hgMaterial.modificationsSince(workingFolder, REVISION_0, new TestSubprocessExecutionContext()));
    HgMaterial newMaterial = MaterialsMother.hgMaterial(hgMaterial.getUrl());
    newMaterial.setFilter(new Filter(new IgnoredFiles("**/*.txt")));
    final MaterialRevision after = findNewRevision(original, newMaterial, workingFolder, new TestSubprocessExecutionContext());
    assertThat(after.getMaterial(), is(newMaterial));
}
Also used : Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Example 22 with IgnoredFiles

use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.

the class MaterialRevisionTest method shouldIncludeJavaFileWithSemanticallyEqualsIgnoreFilter.

@Test
public void shouldIncludeJavaFileWithSemanticallyEqualsIgnoreFilter() throws Exception {
    MaterialRevision original = new MaterialRevision(hgMaterial, hgMaterial.modificationsSince(workingFolder, REVISION_0, new TestSubprocessExecutionContext()));
    Filter filter = new Filter(new IgnoredFiles("**/*.doc"), new IgnoredFiles("*.doc"));
    GoConfigMother.createPipelineConfig(filter, (ScmMaterialConfig) hgMaterial.config());
    checkInFiles(hgMaterial, "A.java");
    checkInFiles(hgMaterial, "B.doc");
    checkInFiles(hgMaterial, "C.pdf");
    MaterialRevision newRev = findNewRevision(original, hgMaterial, workingFolder, new TestSubprocessExecutionContext());
    assertThat(newRev.filter(original), is(newRev));
}
Also used : Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Example 23 with IgnoredFiles

use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.

the class SCMConfigXmlLoaderTest method shouldReadFolderAndFilterForPluggableSCMMaterialConfig.

@Test
public void shouldReadFolderAndFilterForPluggableSCMMaterialConfig() throws Exception {
    String xml = "<cruise schemaVersion='" + GoConstants.CONFIG_SCHEMA_VERSION + "'>\n" + "<scms>\n" + "    <scm id='scm-id' name='scm-name'>\n" + "		<pluginConfiguration id='plugin-id' version='1.0'/>\n" + "      <configuration>\n" + "        <property>\n" + "          <key>url</key>\n" + "          <value>http://go</value>\n" + "        </property>\n" + "      </configuration>\n" + "    </scm>\n" + "  </scms>" + "<pipelines group=\"group_name\">\n" + "  <pipeline name=\"new_name\">\n" + "    <materials>\n" + "      <scm ref='scm-id' dest='dest'>\n" + "            <filter>\n" + "                <ignore pattern=\"x\"/>\n" + "                <ignore pattern=\"y\"/>\n" + "            </filter>\n" + "      </scm>\n" + "    </materials>\n" + "    <stage name=\"stage_name\">\n" + "      <jobs>\n" + "        <job name=\"job_name\" />\n" + "      </jobs>\n" + "    </stage>\n" + "  </pipeline>\n" + "</pipelines></cruise>";
    GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(xml);
    PipelineConfig pipelineConfig = goConfigHolder.config.pipelineConfigByName(new CaseInsensitiveString("new_name"));
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) pipelineConfig.materialConfigs().get(0);
    assertThat(pluggableSCMMaterialConfig.getSCMConfig(), is(goConfigHolder.config.getSCMs().get(0)));
    assertThat(pluggableSCMMaterialConfig.getFolder(), is("dest"));
    assertThat(pluggableSCMMaterialConfig.filter(), is(new Filter(new IgnoredFiles("x"), new IgnoredFiles("y"))));
}
Also used : GoConfigHolder(com.thoughtworks.go.config.GoConfigHolder) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.Test)

Example 24 with IgnoredFiles

use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldNotTriggerPipelineWhenOnlyValidChangesAreIgnoredFiles.

@Test
public void shouldNotTriggerPipelineWhenOnlyValidChangesAreIgnoredFiles() throws Exception {
    // p1  <- SVN
    // |    /
    // v   v
    // p2 <- git (BL)
    SvnMaterial svn = u.wf(new SvnMaterial("url", "username", "password", false), "folder1");
    u.checkinInOrder(svn, "s1", "s2");
    GitMaterial git = u.wf(new GitMaterial("git"), "folder2");
    git.setFilter(new Filter(new IgnoredFiles("ignored.txt")));
    u.checkinInOrder(git, "g1");
    u.checkinFile(git, "g2", new File("ignored.txt"), ModifiedAction.modified);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(svn));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1), u.m(svn), u.m(git));
    String p1_1 = u.runAndPass(p1, "s1");
    String p2_1 = u.runAndPass(p2, p1_1, "s1", "g1");
    MaterialRevisions given = u.mrs(new MaterialRevision[] { u.mr(p1, false, p1_1), u.mr(svn, true, "s2"), u.mr(git, true, "g2") });
    MaterialRevisions previousRevisions = u.mrs(new MaterialRevision[] { u.mr(p1, false, p1_1), u.mr(svn, true, "s1"), u.mr(git, true, "g1") });
    AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, p2.config.name().toString(), systemEnvironment, materialChecker);
    pipelineTimeline.update();
    BuildCause buildCause = autoBuild.onModifications(given, false, previousRevisions);
    assertThat(buildCause, is(nullValue()));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Filter(com.thoughtworks.go.config.materials.Filter) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) File(java.io.File) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 25 with IgnoredFiles

use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldTriggerPipelineWhenThereAreOnlyIgnoredChanges_WithFanInOff.

@Test
public void shouldTriggerPipelineWhenThereAreOnlyIgnoredChanges_WithFanInOff() throws Exception {
    // p1  <- git (BL)
    // |    /
    // v   v
    // p2
    SystemEnvironment env = mock(SystemEnvironment.class);
    when(env.enforceRevisionCompatibilityWithUpstream()).thenReturn(false);
    GitMaterial git = u.wf(new GitMaterial("git"), "folder2");
    git.setFilter(new Filter(new IgnoredFiles("ignored.txt")));
    u.checkinInOrder(git, "g1");
    u.checkinFile(git, "g2", new File("ignored.txt"), ModifiedAction.modified);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1), u.m(git));
    String p1_1 = u.runAndPass(p1, "g1");
    String p2_1 = u.runAndPass(p2, p1_1, "g1");
    MaterialRevisions given = u.mrs(new MaterialRevision[] { u.mr(p1, false, p1_1), u.mr(git, true, "g2") });
    MaterialRevisions previousRevisions = u.mrs(new MaterialRevision[] { u.mr(p1, true, p1_1), u.mr(git, true, "g1") });
    AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, p2.config.name().toString(), env, materialChecker);
    pipelineTimeline.update();
    BuildCause buildCause = autoBuild.onModifications(given, true, previousRevisions);
    assertThat(buildCause, is(notNullValue()));
    assertThat(buildCause.getMaterialRevisions(), is(given));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Filter(com.thoughtworks.go.config.materials.Filter) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) File(java.io.File) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Aggregations

Filter (com.thoughtworks.go.config.materials.Filter)26 IgnoredFiles (com.thoughtworks.go.config.materials.IgnoredFiles)26 Test (org.junit.Test)24 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)10 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)6 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)6 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)6 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)5 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)5 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)5 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)5 HashMap (java.util.HashMap)5 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)4 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)4 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)4 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)3