You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/05/16 20:34:12 UTC

[3/6] git commit: [#6232] ticket:351 zip helper

[#6232] ticket:351 zip helper


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/8791885e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/8791885e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/8791885e

Branch: refs/heads/master
Commit: 8791885e71b8fce23a26829c3739102c6e461dac
Parents: 2d6d698
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed May 15 09:37:58 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 16 18:28:18 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8791885e/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 53d166f..f760e3e 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -23,6 +23,7 @@ import mimetypes
 import logging
 import string
 import re
+from subprocess import Popen
 from difflib import SequenceMatcher
 from hashlib import sha1
 from datetime import datetime
@@ -1342,4 +1343,18 @@ def topological_sort(graph):
                 roots.append(child)
     assert not graph, 'Cycle detected'
 
+
+def zip(source, zipfile, exclude=None):
+    """Create zip archive using zip binary."""
+    zipbin = tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')
+    source = source.rstrip('/')
+    # this is needed to get proper prefixes inside zip-file
+    working_dir = os.path.dirname(source)
+    source_fn = os.path.basename(source)
+    command = [zipbin, '-r', zipfile, source_fn]
+    if exclude:
+        command += ['-x', exclude]
+    Popen(command, cwd=working_dir).communicate()
+
+
 Mapper.compile_all()