| | |
| | | String contentA = JGitUtils.getStringContent(repository, (RevTree) null, "java.java");
|
| | | RevCommit commit = JGitUtils.getCommit(repository, Constants.HEAD);
|
| | | String contentB = JGitUtils.getStringContent(repository, commit.getTree(), "java.java");
|
| | |
|
| | | assertTrue("ContentA is null!", contentA != null && contentA.length() > 0);
|
| | | assertTrue("ContentB is null!", contentB != null && contentB.length() > 0);
|
| | | assertTrue(contentA.equals(contentB));
|
| | |
|
| | | String contentC = JGitUtils.getStringContent(repository, commit.getTree(), "missing.txt");
|
| | |
|
| | | // manually construct a blob, calculate the hash, lookup the hash in git
|
| | |
| | | String sha1 = StringUtils.getSHA1(sb.toString());
|
| | | String contentD = JGitUtils.getStringContent(repository, sha1);
|
| | | repository.close();
|
| | | assertTrue("ContentA is null!", contentA != null && contentA.length() > 0);
|
| | | assertTrue("ContentB is null!", contentB != null && contentB.length() > 0);
|
| | | assertTrue(contentA.equals(contentB));
|
| | | assertNull(contentC);
|
| | | assertTrue(contentA.equals(contentD));
|
| | | }
|
| | |
| | | assertEquals(0, JGitUtils.getFilesInPath(null, null, null).size());
|
| | | Repository repository = GitBlitSuite.getHelloworldRepository();
|
| | | List<PathModel> files = JGitUtils.getFilesInPath(repository, null, null);
|
| | | repository.close();
|
| | | assertTrue(files.size() > 10);
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void testFilesInPath2() throws Exception {
|
| | | assertEquals(0, JGitUtils.getFilesInPath2(null, null, null).size());
|
| | | Repository repository = GitBlitSuite.getHelloworldRepository();
|
| | | List<PathModel> files = JGitUtils.getFilesInPath2(repository, null, null);
|
| | | repository.close();
|
| | | assertTrue(files.size() > 10);
|
| | | }
|
| | |
| | |
|
| | | @Test
|
| | | public void testZip() throws Exception {
|
| | | assertFalse(CompressionUtils.zip(null, null, null, null));
|
| | | assertFalse(CompressionUtils.zip(null, null, null, null, null));
|
| | | Repository repository = GitBlitSuite.getHelloworldRepository();
|
| | | File zipFileA = new File(GitBlitSuite.REPOSITORIES, "helloworld.zip");
|
| | | FileOutputStream fosA = new FileOutputStream(zipFileA);
|
| | | boolean successA = CompressionUtils.zip(repository, null, Constants.HEAD, fosA);
|
| | | boolean successA = CompressionUtils.zip(repository, null, null, Constants.HEAD, fosA);
|
| | | fosA.close();
|
| | |
|
| | | File zipFileB = new File(GitBlitSuite.REPOSITORIES, "helloworld-java.zip");
|
| | | FileOutputStream fosB = new FileOutputStream(zipFileB);
|
| | | boolean successB = CompressionUtils.zip(repository, "java.java", Constants.HEAD, fosB);
|
| | | boolean successB = CompressionUtils.zip(repository, null, "java.java", Constants.HEAD, fosB);
|
| | | fosB.close();
|
| | |
|
| | | repository.close();
|