Skip to content

Commit 3a8b612

Browse files
committed
Treat dot files and folders as internal
1 parent 3ca4640 commit 3a8b612

File tree

7 files changed

+30
-8
lines changed

7 files changed

+30
-8
lines changed

CHANGELOG.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/main[co
1717

1818
Bug Fixes::
1919

20-
* Fix excluding sources when enclosing parent path starts with _ (#544)
20+
* Fix excluding sources when enclosing parent path starts with _ (#546)
21+
* Treat dot files and folders same as internal #5505)
2122

2223
== v2.2.0 (2021-07-18)
2324

src/main/java/org/asciidoctor/maven/io/AsciidoctorFileScanner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class AsciidoctorFileScanner {
2424
public static String[] INTERNAL_FOLDERS_AND_FILES_PATTERNS = {
2525
"**/_*.*",
2626
"**/_*",
27+
"**/.*",
2728
"**/_*/**/*.*",
2829
};
2930

@@ -40,7 +41,8 @@ public class AsciidoctorFileScanner {
4041
"docinfo-footer.xml",
4142
"*-docinfo.xml",
4243
"*-docinfo-header.xml",
43-
"*-docinfo-footer.xml"};
44+
"*-docinfo-footer.xml"
45+
};
4446

4547

4648
private final BuildContext buildContext;

src/main/java/org/asciidoctor/maven/process/SourceDocumentFinder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ private List<File> find(Path sourceDirectory, Pattern sourceDocumentPattern) {
5959
.filter(path -> sourceDocumentPattern.matcher(path.getFileName().toString()).matches())
6060
.filter(path -> {
6161
for (Path part : sourceDirectory.relativize(path)) {
62-
if (part.toString().startsWith("_")) {
62+
char firstCharacter = part.toString().charAt(0);
63+
if (firstCharacter == '_' || firstCharacter == '.') {
6364
return false;
6465
}
6566
}

src/test/java/org/asciidoctor/maven/AsciidoctorMojoTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,11 @@ public void should_not_copy_custom_source_documents_when_custom_extensions_are_s
667667
*/
668668
private void assertEqualsStructure(File[] expected, File[] actual) {
669669

670-
671670
List<File> sanitizedExpected = Arrays.stream(expected)
672-
.filter(file -> !file.getName().startsWith("_"))
671+
.filter(file -> {
672+
char firstChar = file.getName().charAt(0);
673+
return firstChar != '_' && firstChar != '.';
674+
})
673675
.collect(Collectors.toList());
674676

675677
List<String> expectedNames = sanitizedExpected.stream().map(File::getName).collect(Collectors.toList());
@@ -691,7 +693,7 @@ private void assertEqualsStructure(File[] expected, File[] actual) {
691693
if (htmls.length > 0) {
692694
File[] asciidocs = expectedFile.listFiles(f -> {
693695
String asciidocFilePattern = ".*\\." + AsciidoctorFileScanner.ASCIIDOC_FILE_EXTENSIONS_REG_EXP + "$";
694-
return f.getName().matches(asciidocFilePattern) && !f.getName().startsWith("_");
696+
return f.getName().matches(asciidocFilePattern) && !f.getName().startsWith("_") && !f.getName().startsWith(".");
695697
});
696698
Assertions.assertThat(htmls).hasSize(asciidocs.length);
697699
}

src/test/java/org/asciidoctor/maven/process/SourceDocumentFinderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void should_exclude_hidden_sources() {
105105
// then
106106
assertThat(files)
107107
.hasSize(6)
108-
.allMatch(file -> !file.getName().startsWith("_"));
108+
.allMatch(file -> !file.getName().startsWith("_") || !file.getName().startsWith("."));
109109
}
110110

111111
@Test
@@ -144,7 +144,7 @@ private boolean isContainedInInternalDirectory(File file) {
144144
int cursor = 0;
145145
do {
146146
cursor = path.indexOf(File.separator, cursor + 1);
147-
if (path.charAt(cursor + 1) == '_')
147+
if (path.charAt(cursor + 1) == '_' || path.charAt(cursor + 1) == '.')
148148
return true;
149149
} while (cursor != -1);
150150
return false;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:toc: left
2+
:icons:
3+
4+
== Summary
5+
This document won't get converted by default because it is inside a hidden folder. +
6+
Hidden folders begin with underscore `.`.
7+
8+
TIP: How cool is this?
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:toc: left
2+
:icons:
3+
4+
== Summary
5+
This document won't get converted by default because it considered "internal". +
6+
That is, is prefixed with a dot `.`.
7+
8+
TIP: How cool is this?

0 commit comments

Comments
 (0)