From 56c549e384b1a648c77bbd09a2cc77976e8a64de Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Tue, 24 May 2011 17:39:55 -0400 Subject: [PATCH] Documentation. --- src/com/gitblit/tests/JGitUtilsTest.java | 34 +++++++++++++++++++++++++++++++++- 1 files changed, 33 insertions(+), 1 deletions(-) diff --git a/src/com/gitblit/tests/JGitUtilsTest.java b/src/com/gitblit/tests/JGitUtilsTest.java index 0ebcd71..11b7712 100644 --- a/src/com/gitblit/tests/JGitUtilsTest.java +++ b/src/com/gitblit/tests/JGitUtilsTest.java @@ -1,6 +1,7 @@ package com.gitblit.tests; import java.io.File; +import java.io.FileOutputStream; import java.util.Date; import java.util.List; @@ -15,6 +16,7 @@ import org.eclipse.jgit.storage.file.FileRepository; import com.gitblit.utils.JGitUtils; +import com.gitblit.utils.JGitUtils.DiffOutputType; import com.gitblit.wicket.models.PathModel.PathChangeModel; import com.gitblit.wicket.models.RefModel; import com.gitblit.wicket.models.TicketModel; @@ -49,6 +51,14 @@ Date date = JGitUtils.getLastChange(r); r.close(); assertTrue("Could not get last repository change date!", date != null); + } + + public void testFirstCommit() throws Exception { + Repository r = getRepository(); + RevCommit commit = JGitUtils.getFirstCommit(r, null); + r.close(); + assertTrue("Could not get first commit!", commit != null); + System.out.println(commit.getName() + " " + commit.getShortMessage()); } public void testRetrieveRevObject() throws Exception { @@ -90,9 +100,31 @@ public void testCommitDiff() throws Exception { Repository r = getRepository(); RevCommit commit = JGitUtils.getCommit(r, Constants.HEAD); - String diff = JGitUtils.getCommitDiff(r, commit, false); + String diff = JGitUtils.getCommitDiff(r, commit, DiffOutputType.PLAIN); r.close(); System.out.println(diff); } + + public void testZip() throws Exception { + Repository r = new FileRepository(new File(repositoriesFolder, "gitblit.git/" + Constants.DOT_GIT)); + FileOutputStream fos = null; + try { + File zipFile = new File("c:/output.zip"); + zipFile.delete(); + fos = new FileOutputStream(zipFile); + if (JGitUtils.zip(r, "src", Constants.HEAD, fos)) { + System.out.println("zip = " + zipFile.length() + " bytes"); + } else { + System.err.println("failed to generate zip file?!"); + } + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Throwable t) { + } + } + } + } } -- Gitblit v1.9.1