Community
Participate
Working Groups
public class GitRepositoryTest { @Rule public TemporaryFolder folder = new TemporaryFolder(); @Test public void testBuild() throws IOException { File directory = folder.newFolder("repo"); FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository jGitRepository = builder.setGitDir(directory).readEnvironment().findGitDir().build(); // print nothing for (File file : directory.listFiles()) { System.out.println(file); } // JGit return isBare() true value even if the folder is empty assertTrue(jGitRepository.isBare()); } }
May consider implement it through `git rev-parse --is-bare-repository`, which may be safer.