Browse Source

fixes dulwich issue #54

Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Marcin Kuzminski 13 years ago
parent
commit
3a3a9fafaf
3 changed files with 13 additions and 3 deletions
  1. 3 1
      dulwich/repo.py
  2. 3 2
      dulwich/server.py
  3. 7 0
      dulwich/tests/test_server.py

+ 3 - 1
dulwich/repo.py

@@ -1251,7 +1251,9 @@ class Repo(BaseRepo):
             self.bare = True
             self._controldir = root
         else:
-            raise NotGitRepository(root)
+            raise NotGitRepository(
+                "No git repository was found at %(path)s" % dict(path=root)
+            )
         self.path = root
         object_store = DiskObjectStore(os.path.join(self.controldir(),
                                                     OBJECTDIR))

+ 3 - 2
dulwich/server.py

@@ -149,8 +149,9 @@ class DictBackend(Backend):
         try:
             return self.repos[path]
         except KeyError:
-            raise NotGitRepository("No git repository was found at %(path)s",
-                path=path)
+            raise NotGitRepository(
+                "No git repository was found at %(path)s" % dict(path=path)
+            )
 
 
 class FileSystemBackend(Backend):

+ 7 - 0
dulwich/tests/test_server.py

@@ -666,6 +666,13 @@ class FileSystemBackendTests(TestCase):
         self.assertRaises(NotGitRepository,
             self.backend.open_repository, os.path.join(self.path, "foo"))
 
+    def test_bad_repo_path(self):
+        repo = MemoryRepo.init_bare([], {})
+        backend = DictBackend({'/': repo})
+
+        self.assertRaises(NotGitRepository,
+                          lambda: backend.open_repository('/ups'))
+
 
 class ServeCommandTests(TestCase):
     """Tests for serve_command."""