| | |
| | | import org.eclipse.jgit.lib.ObjectId;
|
| | | import org.eclipse.jgit.lib.PersonIdent;
|
| | | import org.eclipse.jgit.lib.Repository;
|
| | | import org.eclipse.jgit.lib.RepositoryCache;
|
| | | import org.eclipse.jgit.lib.RepositoryCache.FileKey;
|
| | | import org.eclipse.jgit.revwalk.RevCommit;
|
| | | import org.eclipse.jgit.revwalk.RevTree;
|
| | |
| | | import com.gitblit.models.PathModel;
|
| | | import com.gitblit.models.PathModel.PathChangeModel;
|
| | | import com.gitblit.models.RefModel;
|
| | | import com.gitblit.utils.CompressionUtils;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
|
| | |
| | |
|
| | | @Test
|
| | | public void testFindRepositories() {
|
| | | List<String> list = JGitUtils.getRepositoryList(null, false, true, -1);
|
| | | List<String> list = JGitUtils.getRepositoryList(null, false, true, -1, null);
|
| | | assertEquals(0, list.size());
|
| | | list.addAll(JGitUtils.getRepositoryList(new File("DoesNotExist"), true, true, -1));
|
| | | list.addAll(JGitUtils.getRepositoryList(new File("DoesNotExist"), true, true, -1, null));
|
| | | assertEquals(0, list.size());
|
| | | list.addAll(JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true, -1));
|
| | | list.addAll(JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true, -1, null));
|
| | | assertTrue("No repositories found in " + GitBlitSuite.REPOSITORIES, list.size() > 0);
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void testFindExclusions() {
|
| | | List<String> list = JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true, -1, null);
|
| | | assertTrue("Missing jgit repository?!", list.contains("test/jgit.git"));
|
| | |
|
| | | list = JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true, -1, Arrays.asList("test/jgit\\.git"));
|
| | | assertFalse("Repository exclusion failed!", list.contains("test/jgit.git"));
|
| | |
|
| | | list = JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true, -1, Arrays.asList("test/*"));
|
| | | assertFalse("Repository exclusion failed!", list.contains("test/jgit.git"));
|
| | |
|
| | | list = JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true, -1, Arrays.asList(".*jgit.*"));
|
| | | assertFalse("Repository exclusion failed!", list.contains("test/jgit.git"));
|
| | | assertFalse("Repository exclusion failed!", list.contains("working/jgit"));
|
| | | assertFalse("Repository exclusion failed!", list.contains("working/jgit2"));
|
| | |
|
| | | }
|
| | |
|
| | | @Test
|
| | |
| | | assertEquals(folder.lastModified(), JGitUtils.getLastChange(repository).getTime());
|
| | | assertNull(JGitUtils.getCommit(repository, null));
|
| | | repository.close();
|
| | | assertTrue(GitBlit.self().deleteRepository(repositoryName));
|
| | | RepositoryCache.close(repository);
|
| | | FileUtils.delete(repository.getDirectory(), FileUtils.RECURSIVE);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | assertEquals("-rwxr-xr-x",
|
| | | JGitUtils.getPermissionsFromMode(FileMode.EXECUTABLE_FILE.getBits()));
|
| | | assertEquals("symlink", JGitUtils.getPermissionsFromMode(FileMode.SYMLINK.getBits()));
|
| | | assertEquals("gitlink", JGitUtils.getPermissionsFromMode(FileMode.GITLINK.getBits()));
|
| | | assertEquals("submodule", JGitUtils.getPermissionsFromMode(FileMode.GITLINK.getBits()));
|
| | | assertEquals("missing", JGitUtils.getPermissionsFromMode(FileMode.MISSING.getBits()));
|
| | | }
|
| | |
|
| | |
| | |
|
| | | @Test
|
| | | public void testZip() throws Exception {
|
| | | assertFalse(JGitUtils.zip(null, null, null, null));
|
| | | assertFalse(CompressionUtils.zip(null, null, null, null));
|
| | | Repository repository = GitBlitSuite.getHelloworldRepository();
|
| | | File zipFileA = new File(GitBlitSuite.REPOSITORIES, "helloworld.zip");
|
| | | FileOutputStream fosA = new FileOutputStream(zipFileA);
|
| | | boolean successA = JGitUtils.zip(repository, null, Constants.HEAD, fosA);
|
| | | boolean successA = CompressionUtils.zip(repository, null, Constants.HEAD, fosA);
|
| | | fosA.close();
|
| | |
|
| | | File zipFileB = new File(GitBlitSuite.REPOSITORIES, "helloworld-java.zip");
|
| | | FileOutputStream fosB = new FileOutputStream(zipFileB);
|
| | | boolean successB = JGitUtils.zip(repository, "java.java", Constants.HEAD, fosB);
|
| | | boolean successB = CompressionUtils.zip(repository, "java.java", Constants.HEAD, fosB);
|
| | | fosB.close();
|
| | |
|
| | | repository.close();
|