incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [2/3] git commit: [#6069] ticket:324 added prefix to zip tarball
Date Fri, 26 Apr 2013 14:40:45 GMT
[#6069] ticket:324 added prefix to zip tarball


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

Branch: refs/heads/master
Commit: 49933de99f876d44db7663094145143ff50d55a4
Parents: 352b74b
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Thu Apr 25 04:10:47 2013 +0400
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Fri Apr 26 14:36:08 2013 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py                   |   12 +++++++-----
 ForgeSVN/forgesvn/tests/model/test_repository.py |    3 +++
 2 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/49933de9/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 8fdf628..2994aeb 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -29,7 +29,7 @@ from datetime import datetime
 import tempfile
 import tarfile
 from shutil import rmtree
-from zipfile import ZipFile
+from zipfile import ZipFile, ZIP_DEFLATED
 
 import tg
 import pysvn
@@ -640,8 +640,8 @@ class SVNImplementation(M.RepositoryImplementation):
     def tarball(self, commit):
         if not os.path.exists(self._repo.tarball_path):
             os.makedirs(self._repo.tarball_path)
-        path = os.path.join(self._repo.tarball_path, commit)
         archive_name = self._repo.tarball_filename(commit)
+        path = os.path.join(self._repo.tarball_path, archive_name)
         filename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.zip'))
         tmpfilename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.tmp'))
         if os.path.exists(path):
@@ -651,9 +651,11 @@ class SVNImplementation(M.RepositoryImplementation):
                              path,
                              revision=pysvn.Revision(pysvn.opt_revision_kind.number, commit))
             with ZipFile(tmpfilename, 'w') as tarball_zip:
-                for dirname, subdirs, files in os.walk(path):
-                    for f in files:
-                        tarball_zip.write(os.path.join(dirname, f), os.path.relpath(os.path.join(dirname,
f), path))
+               for root, dirs, files in os.walk(path):
+                    for name in files:
+                        file_to_zip = os.path.join(root, name)
+                        arcname = file_to_zip[len(os.path.dirname(path)):].strip('/')
+                        tarball_zip.write(file_to_zip, arcname, compress_type=ZIP_DEFLATED)
 
             os.rename(tmpfilename, filename)
         finally:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/49933de9/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 8107829..68e884c 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -21,6 +21,7 @@ import unittest
 import pkg_resources
 from itertools import count, product
 from datetime import datetime
+from zipfile import ZipFile
 
 from collections import defaultdict
 from pylons import tmpl_context as c
@@ -292,6 +293,8 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         assert_equal(self.repo.tarball_url('1'), 'file:///svn/t/te/test/testsvn/test-src-1.zip')
         self.repo.tarball('1')
         assert os.path.isfile("/tmp/tarball/svn/t/te/test/testsvn/test-src-1.zip")
+        tarball_zip = ZipFile('/tmp/tarball/svn/t/te/test/testsvn/test-src-1.zip', 'r')
+        assert_equal(tarball_zip.namelist(), ['test-src-1/README'])
 
     def test_is_empty(self):
         assert not self.repo.is_empty()


Mime
View raw message