|
@@ -0,0 +1,60 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+"""Tests for dulwich.porcelain."""
|
|
|
+
|
|
|
+from cStringIO import StringIO
|
|
|
+import shutil
|
|
|
+import tarfile
|
|
|
+import tempfile
|
|
|
+
|
|
|
+from dulwich.porcelain import (
|
|
|
+ archive,
|
|
|
+ )
|
|
|
+from dulwich.repo import Repo
|
|
|
+from dulwich.tests.utils import (
|
|
|
+ make_object,
|
|
|
+ make_commit,
|
|
|
+ )
|
|
|
+from dulwich.tests import (
|
|
|
+ TestCase,
|
|
|
+ )
|
|
|
+from dulwich.tests.utils import (
|
|
|
+ build_commit_graph,
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+class ArchiveTests(TestCase):
|
|
|
+ """Tests for the archive command."""
|
|
|
+
|
|
|
+ def setUp(self):
|
|
|
+ super(TestCase, self).setUp()
|
|
|
+ repo_dir = tempfile.mkdtemp()
|
|
|
+ self.addCleanup(shutil.rmtree, repo_dir)
|
|
|
+ self.repo = Repo.init_bare(repo_dir)
|
|
|
+
|
|
|
+ def test_simple(self):
|
|
|
+ c1, c2, c3 = build_commit_graph(self.repo.object_store, [[1], [2, 1], [3, 1, 2]])
|
|
|
+ self.repo.refs["refs/heads/master"] = c3.id
|
|
|
+ out = StringIO()
|
|
|
+ err = StringIO()
|
|
|
+ archive(self.repo.path, "refs/heads/master", outstream=out, errstream=err)
|
|
|
+ self.assertEquals("", err.getvalue())
|
|
|
+ tf = tarfile.TarFile(fileobj=out)
|
|
|
+ self.addCleanup(tf.close)
|
|
|
+ self.assertEquals([], tf.getnames())
|