public static PluggableSCMMaterialConfig pluggableSCMMaterialConfig() { Filter filter = new Filter(new IgnoredFiles("**/*.html"), new IgnoredFiles("**/foobar/")); return pluggableSCMMaterialConfig("scm-id", "des-folder", filter); }
private Filter toFilter(List<String> filterList) { Filter filter = new Filter(); if (filterList == null) return filter; for (String pattern : filterList) { filter.add(new IgnoredFiles(pattern)); } return filter; }
public static Filter fromJSON(JsonReader jsonReader) { Filter filter = new Filter(); filter.clear(); jsonReader.readArrayIfPresent("ignore", ignoredFiles -> { ignoredFiles.forEach(ignoredFile -> { filter.add(new IgnoredFiles(ignoredFile.getAsString())); }); }); return filter; } }
public static GitMaterialConfig gitMaterialConfig() { Filter filter = new Filter(new IgnoredFiles("**/*.html"), new IgnoredFiles("**/foobar/")); return new GitMaterialConfig(new UrlArgument("http://user:password@funk.com/blank"), "branch", "sub_module_folder", false, filter, false, "destination", new CaseInsensitiveString("AwesomeGitMaterial"), true); }
@Test public void shouldIncludeModificationsIfAnyFileIsNotIgnored() { HgMaterialConfig materialConfig = MaterialConfigsMother.hgMaterialConfig(); Filter filter = new Filter(Arrays.asList(new IgnoredFiles("*.doc"), new IgnoredFiles("*.pdf"))); materialConfig.setFilter(filter); Modifications modifications = new Modifications(multipleCheckin(aCheckIn("100", "a.doc", "a.pdf", "a.java"))); assertThat(modifications.shouldBeIgnoredByFilterIn(materialConfig), is(false)); }
@Test public void shouldIgnoreWhenTheTextDoesMatchDocumentUnderRoot() { IgnoredFiles ignore = new IgnoredFiles("a.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc"), is(true)); }
@Test public void shouldIgnoreIfTextIsUnderAFolderMatchingTheGivenFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/*Test*/*"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "B" + separator + "SomethingTestThis" + separator + "isIgnored"), is(true)); }
@Test public void shouldIgnoreWhenTextIsADocumentInAnyFolderWhenDirectoryWildcardNotInTheBegining() throws Exception { IgnoredFiles ignore = new IgnoredFiles("foo*/**/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "foo-hi/bar/a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "bar/baz/b.doc"), is(false)); }
@Test public void shouldIgnoreModificationsIfWildcardBlacklist() { HgMaterialConfig materialConfig = MaterialConfigsMother.hgMaterialConfig(); Filter filter = new Filter(Arrays.asList(new IgnoredFiles("**/*"))); materialConfig.setFilter(filter); Modifications modifications = new Modifications(multipleCheckin(aCheckIn("100", "a.doc", "a.pdf", "a.java"))); assertThat(modifications.shouldBeIgnoredByFilterIn(materialConfig), is(true)); }
public static SvnMaterialConfig svnMaterialConfig(String svnUrl, String folder, boolean autoUpdate) { SvnMaterialConfig materialConfig = new SvnMaterialConfig(new UrlArgument(svnUrl), "user", "pass", true, new GoCipher(), autoUpdate, new Filter(new IgnoredFiles("*.doc")), false, folder, new CaseInsensitiveString("svn-material")); materialConfig.setPassword("pass"); return materialConfig; }
@Test public void shouldSkipDiot() throws Exception { IgnoredFiles ignore = new IgnoredFiles("helper/*.*"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "helper" + separator + "configuration_reference.html"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "helper" + separator + "conf-docs" + separator + "configuration_reference.html"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "helper" + separator + "resources" + separator + "images" + separator + "cruise" + separator + "dependent_build.png"), is(false)); }
@Test public void shouldIgnoreWhenTextIsADocumentInAnyFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "B" + separator + "a.doc"), is(true)); }
@Test public void shouldIncludeWhenTheTextUnderRootIsNotADocument() { IgnoredFiles ignore = new IgnoredFiles("*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.pdf"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc.aaa"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(false)); }
@Test public void shouldIncludeIfTheTextIsNotADocumentInTheSpecifiedFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("ROOTFOLDER/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "shouldNotBeIgnored.doc"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "ANYFOLDER" + separator + "shouldNotBeIgnored.doc"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "ROOTFOLDER" + separator + "" + "ANYFOLDER" + separator + "shouldNotBeIgnored.doc"), is(false)); }
@Test public void shouldIgnoreModificationsIfInvertFilterAndSpecificFileNotChanged2() { HgMaterialConfig materialConfig = MaterialConfigsMother.hgMaterialConfig(); Filter filter = new Filter(Arrays.asList(new IgnoredFiles("foo/bar.baz"))); materialConfig.setFilter(filter); materialConfig.setInvertFilter(true); Modifications modifications = new Modifications(multipleCheckin(aCheckIn("100", "a.java", "foo", "bar.baz", "foo/bar.qux"))); assertThat(modifications.shouldBeIgnoredByFilterIn(materialConfig), is(true)); }
@Test public void shouldIncludeWhenTheTextDoesnotMatchDocumentUnderRoot() { IgnoredFiles ignore = new IgnoredFiles("a.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "b.doc"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc1"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "B" + separator + "a.doc"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(false)); }
@Test public void shouldEscapeAllValidSpecialCharactersInPattern(){//see mingle #5700 hgMaterialConfig = new TfsMaterialConfig(new GoCipher()); IgnoredFiles ignore = new IgnoredFiles("$/tfs_repo/Properties/*.*"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "$/tfs_repo" + separator + "Properties" + separator + "AssemblyInfo.cs"), is(true)); }
@Test public void shouldAddErrorToItsErrorCollection() { IgnoredFiles ignore = new IgnoredFiles("helper/*.*"); Filter filter = new Filter(ignore); filter.addError("key", "some error"); assertThat(filter.errors().on("key"), is("some error")); } }
@Test public void shouldIgnoreDocumentWhenCheckin() throws Exception { MaterialRevision original = new MaterialRevision(hgMaterial, hgMaterial.modificationsSince(workingFolder, REVISION_0, new TestSubprocessExecutionContext())); Filter filter = new Filter(new IgnoredFiles("helper/**/*.*")); hgMaterial.setFilter(filter); checkInFiles(hgMaterial, "helper/topics/installing_go_agent.xml", "helper/topics/installing_go_server.xml"); MaterialRevision newRev = findNewRevision(original, hgMaterial, workingFolder, new TestSubprocessExecutionContext()); assertThat(newRev.filter(original), is(original)); }
@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)); }