Search in sources :

Example 16 with IgnoredFiles

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

the class PipelineConfigDependencyGraphTest method shouldReturnIfSharedRevisionsAreIgnoredByAllDaddys.

@Test
public void shouldReturnIfSharedRevisionsAreIgnoredByAllDaddys() throws Exception {
    SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
    GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url");
    P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
    firstOrderP4Material.setFilter(new Filter(new IgnoredFiles("foo")));
    PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", MaterialConfigsMother.hgMaterialConfig(), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first")));
    PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", filteredHgMaterialConfig("phigar"), firstOrderGitMaterial, new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
    PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, firstOrderP4Material, filteredHgMaterialConfig("phigar"), new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
    PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", filteredHgMaterialConfig("phigar"), firstOrderP4Material);
    PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
    PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
    PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
    Modification modification = new Modification("user", "comment", "i@u.com", new Date(), "foo");
    modification.createModifiedFile("phigar", "", ModifiedAction.added);
    boolean ignored = dependencyGraph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, modification));
    assertThat(ignored, is(true));
    ignored = dependencyGraph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, ModificationsMother.oneModifiedFile("Silly")));
    assertThat(ignored, is(false));
    MaterialRevisions materialRevisions = ModificationsMother.createSvnMaterialRevisions(modification);
    materialRevisions.addAll(ModificationsMother.createP4MaterialRevisions(modification));
    materialRevisions.addAll(ModificationsMother.createHgMaterialWithMultipleRevisions(1, modification));
    ignored = up2Graph.isRevisionsOfSharedMaterialsIgnored(materialRevisions);
    assertThat(ignored, is(true));
    ignored = up2Graph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, ModificationsMother.oneModifiedFile("Silly")));
    assertThat(ignored, is(false));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 17 with IgnoredFiles

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

the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsGitWithBlacklist.

@Test
public void shouldConvertConfigMaterialWhenConfigRepoIsGitWithBlacklist() {
    // this url would be configured inside xml config-repo section
    GitMaterialConfig configRepoMaterial = new GitMaterialConfig("url");
    when(context.configMaterial()).thenReturn(configRepoMaterial);
    CRConfigMaterial crConfigMaterial = new CRConfigMaterial();
    crConfigMaterial.setFilter(new CRFilter(filter, false));
    MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context);
    assertNull("shouldSetEmptyMaterialNameAsInConfigRepoSourceCode", materialConfig.getName());
    GitMaterialConfig gitMaterialConfig = (GitMaterialConfig) materialConfig;
    assertThat(gitMaterialConfig.getAutoUpdate(), is(true));
    assertThat(gitMaterialConfig.getUrl(), is("url"));
    assertNull(gitMaterialConfig.getFolder());
    assertThat(gitMaterialConfig.getAutoUpdate(), is(true));
    assertThat(gitMaterialConfig.isShallowClone(), is(false));
    Filter blacklistFilter = new Filter(new IgnoredFiles("filter"));
    assertThat(gitMaterialConfig.filter(), is(blacklistFilter));
    assertThat(gitMaterialConfig.getUrl(), is("url"));
    assertThat(gitMaterialConfig.getBranch(), is("master"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Test(org.junit.Test)

Example 18 with IgnoredFiles

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

the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHgWithDestination.

@Test
public void shouldConvertConfigMaterialWhenConfigRepoIsHgWithDestination() {
    // these parameters would be configured inside xml config-repo section
    HgMaterialConfig configRepoMaterial = new HgMaterialConfig(new HgUrlArgument("url"), true, new Filter(new IgnoredFiles("ignore")), false, "folder", new CaseInsensitiveString("name"));
    when(context.configMaterial()).thenReturn(configRepoMaterial);
    CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", "dest1", null);
    MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context);
    assertThat("shouldSetMaterialNameAsInConfigRepoSourceCode", materialConfig.getName().toLower(), is("example"));
    assertThat("shouldUseFolderFromConfigRepoWhenSpecified", materialConfig.getFolder(), is("dest1"));
    HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
    assertThat(hgMaterialConfig.getAutoUpdate(), is(true));
    assertThat(hgMaterialConfig.getFilterAsString(), is("ignore"));
    assertThat(hgMaterialConfig.getUrl(), is("url"));
}
Also used : HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Test(org.junit.Test)

Example 19 with IgnoredFiles

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

the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHg.

@Test
public void shouldConvertConfigMaterialWhenConfigRepoIsHg() {
    // these parameters would be configured inside xml config-repo section
    HgMaterialConfig configRepoMaterial = new HgMaterialConfig(new HgUrlArgument("url"), true, new Filter(new IgnoredFiles("ignore")), false, "folder", new CaseInsensitiveString("name"));
    when(context.configMaterial()).thenReturn(configRepoMaterial);
    CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", null, null);
    MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context);
    assertThat("shouldSetMaterialNameAsInConfigRepoSourceCode", materialConfig.getName().toLower(), is("example"));
    assertThat("shouldUseFolderFromXMLWhenConfigRepoHasNone", materialConfig.getFolder(), is("folder"));
    HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
    assertThat(hgMaterialConfig.getAutoUpdate(), is(true));
    assertThat(hgMaterialConfig.getFilterAsString(), is("ignore"));
    assertThat(hgMaterialConfig.getUrl(), is("url"));
}
Also used : HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Test(org.junit.Test)

Example 20 with IgnoredFiles

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

the class MaterialRevisionTest method shouldIgnoreDocumentCheckin.

@Test
public void shouldIgnoreDocumentCheckin() throws Exception {
    MaterialRevision previousRevision = new MaterialRevision(hgMaterial, hgMaterial.modificationsSince(workingFolder, REVISION_0, new TestSubprocessExecutionContext()));
    Filter filter = new Filter(new IgnoredFiles("**/*.doc"));
    hgMaterial.setFilter(filter);
    checkInFiles(hgMaterial, "user.doc");
    MaterialRevision newRevision = findNewRevision(previousRevision, hgMaterial, workingFolder, new TestSubprocessExecutionContext());
    assertThat(newRevision.filter(previousRevision), is(previousRevision));
}
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)

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