RepositoryManager { public static boolean isGitRepository(Path targetDirectory) { Git repository = null; try { repository = Git.open(targetDirectory.toFile()); return true; } catch (IOException e) { return false; } finally { close(repository); } }  static void close(Git repository); static boolean isGitRepository(Path targetDirectory); static boolean isGitRepository(Path targetDirectory, String remoteGitUrl); static void deleteBranch(Path targetDirectory, String branch, boolean deleteRemoteBranch); static void create(Path targetDirectory, String readmeContentIfEmpty); static void commitAll(Path targetDirectory, String userName, String userEmail, String commitMessage); static void cloneOrCheckout(Path targetDirectory, String repositoryUrl, String branch, String localDirectory); static Git cloneOrCheckout(Path targetDirectory, String repositoryUrl, String username, String password, String branch, String localDirectory); static boolean isTag(Git repository, String branch); static boolean isBranch(Git repository, String branch); static void stash(Path repositoryDirectory, String stashId); static void dropStash(Path repositoryDirectory, String stashId); static void applyStashThenDrop(Path repositoryDirectory, String stashId); static void checkoutExistingBranchOrCreateOrphan(Path repositoryDirectory, boolean isLocalOnly, String username, String password, String branch); static boolean pull(Git repository, String username, String password); static String getLastHash(Git git); static List<SimpleGitHistoryEntry> getHistory(Path repositoryDirectory, int from, int count); static void setRemote(Path repositoryDirectory, String remoteName, String remoteUrl); static String getRemoteUrl(Path repositoryDirectory, String remoteName); static String getCurrentBranchName(Path repositoryDirectory); static boolean isOnBranch(Path repositoryDirectory, String branchName); static void renameBranches(Path repositoryDirectory, Map<String, String> branchOldNameToNewName); static boolean push(Path repositoryDirectory, String username, String password); static boolean push(Path repositoryDirectory, String username, String password, String remoteBranch); static void rebranch(Git git, String localBranch, String remoteBranch); static boolean push(Git git, String username, String password, String localBranch, String remoteBranch); static void fetch(Git git, String username, String password); static void pull(Path repositoryDirectory, String username, String password); static void pull(Path repositoryDirectory, String username, String password, String remoteBranch); static void clean(Path repositoryDirectory);  }
@Test public void isGitRepository() throws Exception { assertThat(RepositoryManager.isGitRepository(localGitPath)).isTrue(); }