allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [7/50] [abbrv] git commit: [#2840] Added gzip compression to snapshot
Date Tue, 12 Mar 2013 20:04:51 GMT
[#2840] Added gzip compression to snapshot

Signed-off-by: Cory Johns <johnsca@geek.net>


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

Branch: refs/heads/si/5453
Commit: b924f741e983bc450f811571f98e75e2e8a5ffc0
Parents: 8b9054a
Author: Cory Johns <johnsca@geek.net>
Authored: Mon Mar 11 22:28:57 2013 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Mon Mar 11 22:29:45 2013 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b924f741/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index d509ceb..0081ead 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -241,7 +241,7 @@ class Repository(Artifact, ActivityObject):
     def tarball_url(self, revision):
         shortname = c.app.repo.project.shortname.replace('/', '-')
         mount_point = c.app.repo.app.config.options.mount_point
-        filename = '%s-%s-%s.tar' % (shortname, mount_point, revision)
+        filename = '%s-%s-%s.tar.gz' % (shortname, mount_point, revision)
         r = os.path.join(self.tool,self.project.url()[1:],self.name,filename)
         return urljoin(tg.config.get('scm.repos.tarball.url_prefix', '/'), r)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b924f741/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 70c8050..c660d69 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -8,6 +8,7 @@ import itertools
 from collections import namedtuple
 from datetime import datetime
 from glob import glob
+import gzip
 
 import tg
 import git
@@ -327,9 +328,10 @@ class GitImplementation(M.RepositoryImplementation):
         mount_point = self._repo.app.config.options.mount_point
         if not os.path.exists(self._repo.tarball_path):
             os.makedirs(self._repo.tarball_path)
-        filename = '%s-%s-%s.tar' % (shortname, mount_point, commit)
-        self._git.archive(open(os.path.join(self._repo.tarball_path, filename), 'w'),
-                          treeish=commit)
+        archive_name = '%s-%s-%s' % (shortname, mount_point, commit)
+        filename = os.path.join(self._repo.tarball_path, archive_name + '.tar.gz')
+        with gzip.open(filename, 'w') as fp:
+            self._git.archive(fp, format='tar', treeish=commit, prefix=archive_name+'/')
 
 class _OpenedGitBlob(object):
     CHUNK_SIZE=4096

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b924f741/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 7cc830e..ac848bc 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -240,9 +240,9 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
 
     def test_tarball(self):
         assert_equal(self.repo.tarball_path, '/tmp/tarball/git/p/test/testgit.git')
-        assert_equal(self.repo.tarball_url('HEAD'), 'file:///git/p/test/testgit.git/test-src-git-HEAD.tar')
+        assert_equal(self.repo.tarball_url('HEAD'), 'file:///git/p/test/testgit.git/test-src-git-HEAD.tar.gz')
         self.repo.tarball('HEAD')
-        assert os.path.isfile("/tmp/tarball/git/p/test/testgit.git/test-src-git-HEAD.tar")
+        assert os.path.isfile("/tmp/tarball/git/p/test/testgit.git/test-src-git-HEAD.tar.gz")
 
 
 class TestGitCommit(unittest.TestCase):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b924f741/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index a3490bc..7c7515a 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -621,10 +621,10 @@ class SVNImplementation(M.RepositoryImplementation):
         self._svn.export(self._url,
                          path,
                          revision=pysvn.Revision(pysvn.opt_revision_kind.number, commit))
-        filename = '%s-%s-%s.tar' % (shortname, mount_point, commit)
-        tar = tarfile.open(os.path.join(self._repo.tarball_path, filename), "w")
-        tar.add(path, arcname=commit)
-        tar.close()
+        archive_name = '%s-%s-%s' % (shortname, mount_point, commit)
+        filename = os.path.join(self._repo.tarball_path, archive_name + '.tar.gz')
+        with tarfile.open(filename, "w:gz") as tar:
+            tar.add(path, arcname=archive_name)
         rmtree(path)
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b924f741/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 f1eba67..2b02ad0 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -267,9 +267,9 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
 
     def test_tarball(self):
         assert_equal(self.repo.tarball_path, '/tmp/tarball/svn/p/test/testsvn')
-        assert_equal(self.repo.tarball_url('1'), 'file:///svn/p/test/testsvn/test-src-1.tar')
+        assert_equal(self.repo.tarball_url('1'), 'file:///svn/p/test/testsvn/test-src-1.tar.gz')
         self.repo.tarball('1')
-        assert os.path.isfile("/tmp/tarball/svn/p/test/testsvn/test-src-1.tar")
+        assert os.path.isfile("/tmp/tarball/svn/p/test/testsvn/test-src-1.tar.gz")
 
 class TestSVNRev(unittest.TestCase):
 


Mime
View raw message