From 048f610cf4a2ca633cf72454831e4164bd82f756 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 2 Jun 2018 12:54:57 +0100 Subject: [PATCH] Rewrite check for valid bare repo --- src/test/java/net/kemitix/gitdb/GitDBTest.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/test/java/net/kemitix/gitdb/GitDBTest.java b/src/test/java/net/kemitix/gitdb/GitDBTest.java index 4018182..418fce9 100644 --- a/src/test/java/net/kemitix/gitdb/GitDBTest.java +++ b/src/test/java/net/kemitix/gitdb/GitDBTest.java @@ -4,6 +4,7 @@ import org.assertj.core.api.WithAssertions; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.InitCommand; import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.lib.Constants; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; @@ -37,19 +38,9 @@ class GitDBTest implements WithAssertions { } private void assertThatIsBareRepo(final Path dbDir) throws IOException { - final DirectoryStream paths = Files.newDirectoryStream(dbDir); - assertThat(paths.iterator()) - .contains( - dbDir.resolve("branches"), - dbDir.resolve("HEAD"), - dbDir.resolve("config"), - dbDir.resolve("refs"), - dbDir.resolve("logs"), - dbDir.resolve("hooks"), - dbDir.resolve("objects") - ); - final List config = Files.readAllLines(dbDir.resolve("config")); - assertThat(config).contains("\tbare = true"); + final Git git = Git.open(dbDir.toFile()); + assertThat(git.getRepository().findRef(Constants.HEAD)).isNotNull(); + assertThat(git.getRepository().isBare()).isTrue(); } private Path dirDoesNotExist() throws IOException {