incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [08/12] git commit: [#6069] ticket:317 Change code snapshots to zip files
Date Fri, 26 Apr 2013 14:53:12 GMT
[#6069] ticket:317 Change code snapshots to zip files


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

Branch: refs/heads/cj/5655
Commit: 352b74b8b981b1ffdcaaa4d2fab522ab4dc41d87
Parents: c01c95e
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Mon Apr 15 16:05:37 2013 +0400
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Fri Apr 26 14:36:07 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py                |    4 ++--
 ForgeGit/forgegit/model/git_repo.py              |    6 +++---
 ForgeGit/forgegit/tests/model/test_repository.py |   14 +++++++-------
 ForgeSVN/forgesvn/model/svn.py                   |   10 +++++++---
 ForgeSVN/forgesvn/tests/model/test_repository.py |    4 ++--
 5 files changed, 21 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/352b74b8/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 8a95993..53d166f 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -272,7 +272,7 @@ class Repository(Artifact, ActivityObject):
         return filename
 
     def tarball_url(self, revision):
-        filename = '%s%s' % (self.tarball_filename(revision), '.tar.gz')
+        filename = '%s%s' % (self.tarball_filename(revision), '.zip')
         r = os.path.join(self.tool,
                          self.project.shortname[:1],
                          self.project.shortname[:2],
@@ -283,7 +283,7 @@ class Repository(Artifact, ActivityObject):
 
     def get_tarball_status(self, revision):
         pathname = os.path.join(self.tarball_path, self.tarball_filename(revision))
-        filename = '%s%s' % (pathname, '.tar.gz')
+        filename = '%s%s' % (pathname, '.zip')
         tmpfilename = '%s%s' % (pathname, '.tmp')
 
         if os.path.isfile(filename):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/352b74b8/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 5c79e34..2511ce0 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -345,11 +345,11 @@ class GitImplementation(M.RepositoryImplementation):
         if not os.path.exists(self._repo.tarball_path):
             os.makedirs(self._repo.tarball_path)
         archive_name = self._repo.tarball_filename(commit)
-        filename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.tar.gz'))
+        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'))
         try:
-            with gzip.open(tmpfilename, 'w') as fp:
-                self._git.archive(fp, format='tar', treeish=commit, prefix=archive_name +
'/')
+            with open(tmpfilename, 'wb') as archive_file:
+                self._git.archive(archive_file, format='zip', treeish=commit, prefix=archive_name
+ '/')
             os.rename(tmpfilename, filename)
         finally:
             if os.path.exists(tmpfilename):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/352b74b8/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 46c2daa..1614069 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -258,12 +258,12 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         self.assertEqual(new_tree.other_ids, orig_tree.other_ids)
 
     def test_tarball(self):
-        if os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tar.gz"):
-            os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tar.gz")
+        if os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip"):
+            os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip")
         assert_equal(self.repo.tarball_path, '/tmp/tarball/git/t/te/test/testgit.git')
-        assert_equal(self.repo.tarball_url('HEAD'), 'file:///git/t/te/test/testgit.git/test-src-git-HEAD.tar.gz')
+        assert_equal(self.repo.tarball_url('HEAD'), 'file:///git/t/te/test/testgit.git/test-src-git-HEAD.zip')
         self.repo.tarball('HEAD')
-        assert os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tar.gz")
+        assert os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip")
 
     def test_all_commit_ids(self):
         cids = list(self.repo.all_commit_ids())
@@ -292,15 +292,15 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
                 'name': u'README'}])
 
     def test_tarball_status(self):
-        if os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tar.gz"):
-            os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tar.gz")
+        if os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip"):
+            os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip")
         if os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tmp"):
             os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tmp")
         if os.path.isdir("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD/"):
             os.removedirs("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD/")
         self.repo.tarball('HEAD')
         assert_equal(self.repo.get_tarball_status('HEAD'), 'ready')
-        os.rename("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tar.gz",
+        os.rename("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip",
                   "/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tmp")
         assert_equal(self.repo.get_tarball_status('HEAD'), 'busy')
         os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tmp")

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/352b74b8/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index de05fd0..8fdf628 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -29,6 +29,7 @@ from datetime import datetime
 import tempfile
 import tarfile
 from shutil import rmtree
+from zipfile import ZipFile
 
 import tg
 import pysvn
@@ -641,7 +642,7 @@ class SVNImplementation(M.RepositoryImplementation):
             os.makedirs(self._repo.tarball_path)
         path = os.path.join(self._repo.tarball_path, commit)
         archive_name = self._repo.tarball_filename(commit)
-        filename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.tar.gz'))
+        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):
             rmtree(path)
@@ -649,8 +650,11 @@ class SVNImplementation(M.RepositoryImplementation):
             self._svn.export(self._url,
                              path,
                              revision=pysvn.Revision(pysvn.opt_revision_kind.number, commit))
-            with tarfile.open(tmpfilename, "w:gz") as tar:
-                tar.add(path, arcname=archive_name)
+            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))
+
             os.rename(tmpfilename, filename)
         finally:
             rmtree(path)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/352b74b8/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 e8fb14e..8107829 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -289,9 +289,9 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
 
     def test_tarball(self):
         assert_equal(self.repo.tarball_path, '/tmp/tarball/svn/t/te/test/testsvn')
-        assert_equal(self.repo.tarball_url('1'), 'file:///svn/t/te/test/testsvn/test-src-1.tar.gz')
+        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.tar.gz")
+        assert os.path.isfile("/tmp/tarball/svn/t/te/test/testsvn/test-src-1.zip")
 
     def test_is_empty(self):
         assert not self.repo.is_empty()


Mime
View raw message