瀏覽代碼

Use PackData.filename attribute.

Jelmer Vernooij 11 年之前
父節點
當前提交
19a7e0d218
共有 3 個文件被更改,包括 11 次插入5 次删除
  1. 4 0
      dulwich/pack.py
  2. 1 1
      dulwich/server.py
  3. 6 4
      dulwich/tests/test_web.py

+ 4 - 0
dulwich/pack.py

@@ -980,6 +980,10 @@ class PackData(object):
             compute_size=_compute_object_size)
         self.pack = None
 
+    @property
+    def filename(self):
+        return os.path.basename(self._filename)
+
     @classmethod
     def from_file(cls, file, size):
         return cls(str(file), file=file, size=size)

+ 1 - 1
dulwich/server.py

@@ -919,7 +919,7 @@ def generate_info_refs(repo):
 def generate_objects_info_packs(repo):
     """Generate an index for for packs."""
     for pack in repo.object_store.packs:
-        yield 'P pack-%s.pack\n' % pack.name()
+        yield 'P %s\n' % pack.data.filename
 
 
 def update_server_info(repo):

+ 6 - 4
dulwich/tests/test_web.py

@@ -254,12 +254,14 @@ class DumbHandlersTestCase(WebTestCase):
         self.assertFalse(self._req.cached)
 
     def test_get_info_packs(self):
-        class TestPack(object):
+        class TestPackData(object):
+
             def __init__(self, sha):
-                self._sha = sha
+                self.filename = "pack-%s.pack" % sha
 
-            def name(self):
-                return self._sha
+        class TestPack(object):
+            def __init__(self, sha):
+                self.data = TestPackData(sha)
 
         packs = [TestPack(str(i) * 40) for i in xrange(1, 4)]