From 59b817a55b04b4bd8c5950a2d97998d3af6d44e3 Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 30 Nov 2012 18:05:35 -0500 Subject: Support alternate compressed download formats (issue-174) --- src/com/gitblit/utils/JGitUtils.java | 69 ------------------------------------ 1 file changed, 69 deletions(-) (limited to 'src/com/gitblit/utils/JGitUtils.java') diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index bc44f00f..9cfb37fd 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -19,7 +19,6 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; @@ -30,8 +29,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; import org.eclipse.jgit.api.CloneCommand; import org.eclipse.jgit.api.FetchCommand; @@ -1723,70 +1720,4 @@ public class JGitUtils { } return success; } - - /** - * Zips the contents of the tree at the (optionally) specified revision and - * the (optionally) specified basepath to the supplied outputstream. - * - * @param repository - * @param basePath - * if unspecified, entire repository is assumed. - * @param objectId - * if unspecified, HEAD is assumed. - * @param os - * @return true if repository was successfully zipped to supplied output - * stream - */ - public static boolean zip(Repository repository, String basePath, String objectId, - OutputStream os) { - RevCommit commit = getCommit(repository, objectId); - if (commit == null) { - return false; - } - boolean success = false; - RevWalk rw = new RevWalk(repository); - TreeWalk tw = new TreeWalk(repository); - try { - tw.addTree(commit.getTree()); - ZipOutputStream zos = new ZipOutputStream(os); - zos.setComment("Generated by Gitblit"); - if (!StringUtils.isEmpty(basePath)) { - PathFilter f = PathFilter.create(basePath); - tw.setFilter(f); - } - tw.setRecursive(true); - while (tw.next()) { - if (tw.getFileMode(0) == FileMode.GITLINK) { - continue; - } - ZipEntry entry = new ZipEntry(tw.getPathString()); - entry.setSize(tw.getObjectReader().getObjectSize(tw.getObjectId(0), - Constants.OBJ_BLOB)); - entry.setComment(commit.getName()); - zos.putNextEntry(entry); - - ObjectId entid = tw.getObjectId(0); - FileMode entmode = tw.getFileMode(0); - RevBlob blob = (RevBlob) rw.lookupAny(entid, entmode.getObjectType()); - rw.parseBody(blob); - - ObjectLoader ldr = repository.open(blob.getId(), Constants.OBJ_BLOB); - byte[] tmp = new byte[4096]; - InputStream in = ldr.openStream(); - int n; - while ((n = in.read(tmp)) > 0) { - zos.write(tmp, 0, n); - } - in.close(); - } - zos.finish(); - success = true; - } catch (IOException e) { - error(e, repository, "{0} failed to zip files from commit {1}", commit.getName()); - } finally { - tw.release(); - rw.dispose(); - } - return success; - } } -- cgit v1.2.3 From 8744a1e9de208117bc6187d9e917b9ed8da83f94 Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Sun, 2 Dec 2012 08:50:55 +0000 Subject: FIX: Allow correct search for RefModel using branch name. DisplayName used previously contained ONLY the last part of ref-spec: this would have not worked when looking for objects with full ref-spec. --- src/com/gitblit/utils/JGitUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/com/gitblit/utils/JGitUtils.java') diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index 9cfb37fd..beaa27da 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -1528,7 +1528,7 @@ public class JGitUtils { try { // search for the branch in local heads for (RefModel ref : JGitUtils.getLocalBranches(repository, false, -1)) { - if (ref.displayName.endsWith(name)) { + if (ref.reference.getName().endsWith(name)) { branch = ref; break; } @@ -1537,7 +1537,7 @@ public class JGitUtils { // search for the branch in remote heads if (branch == null) { for (RefModel ref : JGitUtils.getRemoteBranches(repository, false, -1)) { - if (ref.displayName.endsWith(name)) { + if (ref.reference.getName().endsWith(name)) { branch = ref; break; } -- cgit v1.2.3