Rewrite check for valid bare repo
This commit is contained in:
parent
11575f53e7
commit
048f610cf4
1 changed files with 4 additions and 13 deletions
|
@ -4,6 +4,7 @@ import org.assertj.core.api.WithAssertions;
|
||||||
import org.eclipse.jgit.api.Git;
|
import org.eclipse.jgit.api.Git;
|
||||||
import org.eclipse.jgit.api.InitCommand;
|
import org.eclipse.jgit.api.InitCommand;
|
||||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
|
import org.eclipse.jgit.lib.Constants;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
@ -37,19 +38,9 @@ class GitDBTest implements WithAssertions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatIsBareRepo(final Path dbDir) throws IOException {
|
private void assertThatIsBareRepo(final Path dbDir) throws IOException {
|
||||||
final DirectoryStream<Path> paths = Files.newDirectoryStream(dbDir);
|
final Git git = Git.open(dbDir.toFile());
|
||||||
assertThat(paths.iterator())
|
assertThat(git.getRepository().findRef(Constants.HEAD)).isNotNull();
|
||||||
.contains(
|
assertThat(git.getRepository().isBare()).isTrue();
|
||||||
dbDir.resolve("branches"),
|
|
||||||
dbDir.resolve("HEAD"),
|
|
||||||
dbDir.resolve("config"),
|
|
||||||
dbDir.resolve("refs"),
|
|
||||||
dbDir.resolve("logs"),
|
|
||||||
dbDir.resolve("hooks"),
|
|
||||||
dbDir.resolve("objects")
|
|
||||||
);
|
|
||||||
final List<String> config = Files.readAllLines(dbDir.resolve("config"));
|
|
||||||
assertThat(config).contains("\tbare = true");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path dirDoesNotExist() throws IOException {
|
private Path dirDoesNotExist() throws IOException {
|
||||||
|
|
Loading…
Reference in a new issue