2
0
Эх сурвалжийг харах

Fix server.FileSystemBackend on windows.

Gary van der Merwe 10 жил өмнө
parent
commit
a62b59f67a

+ 2 - 2
dulwich/porcelain.py

@@ -644,7 +644,7 @@ def upload_pack(path=".", inf=None, outf=None):
         outf = getattr(sys.stdout, 'buffer', sys.stdout)
     if inf is None:
         inf = getattr(sys.stdin, 'buffer', sys.stdin)
-    backend = FileSystemBackend()
+    backend = FileSystemBackend(path)
     def send_fn(data):
         outf.write(data)
         outf.flush()
@@ -666,7 +666,7 @@ def receive_pack(path=".", inf=None, outf=None):
         outf = getattr(sys.stdout, 'buffer', sys.stdout)
     if inf is None:
         inf = getattr(sys.stdin, 'buffer', sys.stdin)
-    backend = FileSystemBackend()
+    backend = FileSystemBackend(path)
     def send_fn(data):
         outf.write(data)
         outf.flush()

+ 6 - 4
dulwich/server.py

@@ -183,15 +183,17 @@ class DictBackend(Backend):
 class FileSystemBackend(Backend):
     """Simple backend that looks up Git repositories in the local file system."""
 
-    def __init__(self, root="/"):
+    def __init__(self, root=os.sep):
         super(FileSystemBackend, self).__init__()
-        self.root = (os.path.abspath(root) + "/").replace("//", "/")
+        self.root = os.path.normcase(
+            (os.path.abspath(root) + os.sep).replace(os.sep * 2, os.sep))
 
     def open_repository(self, path):
         logger.debug('opening repository at %s', path)
-        abspath = os.path.abspath(os.path.join(self.root, path)) + "/"
+        abspath = os.path.normcase(
+            os.path.abspath(os.path.join(self.root, path)) + os.sep)
         if not abspath.startswith(self.root):
-            raise NotGitRepository("Invalid path %r" % path)
+            raise NotGitRepository("Path %r not inside root %r" % (path, self.root))
         return Repo(abspath)