From 9197d340db81a245193dff1ecb44889b8e0dfe31 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Tue, 24 May 2011 17:39:38 -0400
Subject: [PATCH] Download zip feature.

---
 src/com/gitblit/tests/JGitUtilsTest.java |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/com/gitblit/tests/JGitUtilsTest.java b/src/com/gitblit/tests/JGitUtilsTest.java
index 196058c..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;
 
@@ -103,5 +104,27 @@
 		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