Răsfoiți Sursa

Implement MemoryRepo.set_description.

Jelmer Vernooij 8 ani în urmă
părinte
comite
c597d35150
3 a modificat fișierele cu 21 adăugiri și 7 ștergeri
  1. 5 0
      NEWS
  2. 7 7
      dulwich/repo.py
  3. 9 0
      dulwich/tests/test_repository.py

+ 5 - 0
NEWS

@@ -5,6 +5,11 @@
  * Skip test that requires sync to synchronize filesystems if os.sync is
    not available. (Koen Martens)
 
+ IMPROVEMENTS
+
+ * Implement MemoryRepo.{set_description,get_description}.
+   (Jelmer Vernooij)
+
 0.16.3	2016-01-14
 
  TEST FIXES

+ 7 - 7
dulwich/repo.py

@@ -1077,6 +1077,13 @@ class MemoryRepo(BaseRepo):
         self._named_files = {}
         self.bare = True
         self._config = ConfigFile()
+        self._description = None
+
+    def set_description(self, description):
+        self._description = description
+
+    def get_description(self):
+        return self._description
 
     def _determine_file_mode(self):
         """Probe the file-system to determine whether permissions can be trusted.
@@ -1122,13 +1129,6 @@ class MemoryRepo(BaseRepo):
         """
         return self._config
 
-    def get_description(self):
-        """Retrieve the repository description.
-
-        This defaults to None, for no description.
-        """
-        return None
-
     @classmethod
     def init_bare(cls, objects, refs):
         """Create a new bare repository in memory.

+ 9 - 0
dulwich/tests/test_repository.py

@@ -98,6 +98,15 @@ class CreateRepositoryTests(TestCase):
         self._check_repo_contents(repo, False)
 
 
+class MemoryRepoTests(TestCase):
+
+    def test_set_description(self):
+        r = MemoryRepo.init_bare([], {})
+        description = b"Some description"
+        r.set_description(description)
+        self.assertEqual(description, r.get_description())
+
+
 class RepositoryRootTests(TestCase):
 
     def mkdtemp(self):