Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore files starting with "_" when indexing guides #6

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/main/java/io/quarkus/search/app/entity/Guide.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.search.app.entity;

import io.quarkus.search.app.hibernate.AnalysisConfigurer;
import io.quarkus.search.app.hibernate.PathWrapper;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
Expand All @@ -13,6 +11,9 @@
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField;

import io.quarkus.search.app.hibernate.AnalysisConfigurer;
import io.quarkus.search.app.hibernate.PathWrapper;

@Entity
@Indexed
public class Guide {
Expand Down Expand Up @@ -41,4 +42,10 @@ public class Guide {
// Using PathWrapper because of https://hibernate.atlassian.net/browse/HSEARCH-4988
public PathWrapper fullContentPath;

@Override
public String toString() {
return "Guide{" +
"relativePath='" + relativePath + '\'' +
'}';
}
}
5 changes: 4 additions & 1 deletion src/main/java/io/quarkus/search/app/fetching/QuarkusIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public void close() throws Exception {

public Stream<Guide> guides() throws IOException {
return Files.list(directory.path().resolve("_guides"))
.filter(path -> FilenameUtils.isExtension(path.getFileName().toString(), "adoc"))
.filter(path -> {
String filename = path.getFileName().toString();
return !filename.startsWith("_") && FilenameUtils.isExtension(filename, "adoc");
})
.map(this::parseGuide);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ class LocalDirectoryTest extends AbstractTest {
@BeforeAll
static void initLocalRepo() throws IOException {
Path guideToFetch = sourceDir.resolve("_guides/" + FETCHED_GUIDE_NAME + ".adoc");
Path adocToIgnore = sourceDir.resolve("_guides/_attributes.adoc");
PathUtils.createParentDirectories(guideToFetch);
Files.writeString(guideToFetch, FETCHED_GUIDE_CONTENT);
PathUtils.createParentDirectories(adocToIgnore);
Files.writeString(adocToIgnore, "ignored");
}
}

Expand All @@ -121,10 +124,12 @@ class GitTest extends AbstractTest {
@BeforeAll
static void initOrigin() throws IOException, GitAPIException {
Path guideToFetch = sourceRepoDir.resolve("_guides/" + FETCHED_GUIDE_NAME + ".adoc");
Path adocToIgnore = sourceRepoDir.resolve("_guides/_attributes.adoc");
try (Git git = Git.init().setDirectory(sourceRepoDir.toFile()).call()) {
PathUtils.createParentDirectories(guideToFetch);

Files.writeString(guideToFetch, "initial");
PathUtils.createParentDirectories(adocToIgnore);
Files.writeString(adocToIgnore, "ignored");
git.add().addFilepattern(".").call();
git.commit().setMessage("First commit").call();

Expand Down
Loading