|
@@ -50,6 +50,7 @@ from dulwich.client import (
|
|
|
TraditionalGitClient,
|
|
|
_extract_symrefs_and_agent,
|
|
|
_remote_error_from_stderr,
|
|
|
+ _win32_url_to_path,
|
|
|
check_wants,
|
|
|
default_urllib3_manager,
|
|
|
get_credentials_from_store,
|
|
@@ -671,33 +672,37 @@ class TestGetTransportAndPathFromUrl(TestCase):
|
|
|
self.assertIsInstance(c, LocalGitClient)
|
|
|
self.assertEqual("/home/jelmer/foo", path)
|
|
|
|
|
|
+ def test_win32_url_to_path(self):
|
|
|
+ def check(url, expected):
|
|
|
+ parsed = urlparse(url)
|
|
|
+ self.assertEqual(_win32_url_to_path(parsed), expected)
|
|
|
+
|
|
|
+ check("file:C:/foo.bar/baz", "C:\\foo.bar\\baz")
|
|
|
+ check("file:/C:/foo.bar/baz", "C:\\foo.bar\\baz")
|
|
|
+ check("file://C:/foo.bar/baz", "C:\\foo.bar\\baz")
|
|
|
+ check("file:///C:/foo.bar/baz", "C:\\foo.bar\\baz")
|
|
|
+
|
|
|
@patch("os.name", "nt")
|
|
|
@patch("sys.platform", "win32")
|
|
|
def test_file_win(self) -> None:
|
|
|
- # `_win32_url_to_path` uses urllib.request.url2pathname, which is set to
|
|
|
- # `ntutl2path.url2pathname` when `os.name==nt`
|
|
|
- from nturl2path import url2pathname
|
|
|
-
|
|
|
- with patch("dulwich.client.url2pathname", url2pathname):
|
|
|
- expected = "C:\\foo.bar\\baz"
|
|
|
- for file_url in [
|
|
|
- "file:C:/foo.bar/baz",
|
|
|
- "file:/C:/foo.bar/baz",
|
|
|
- "file://C:/foo.bar/baz",
|
|
|
- "file://C://foo.bar//baz",
|
|
|
- "file:///C:/foo.bar/baz",
|
|
|
- ]:
|
|
|
- c, path = get_transport_and_path(file_url)
|
|
|
- self.assertIsInstance(c, LocalGitClient)
|
|
|
- self.assertEqual(path, expected)
|
|
|
-
|
|
|
- for remote_url in [
|
|
|
- "file://host.example.com/C:/foo.bar/baz"
|
|
|
- "file://host.example.com/C:/foo.bar/baz"
|
|
|
- "file:////host.example/foo.bar/baz",
|
|
|
- ]:
|
|
|
- with self.assertRaises(NotImplementedError):
|
|
|
- c, path = get_transport_and_path(remote_url)
|
|
|
+ expected = "C:\\foo.bar\\baz"
|
|
|
+ for file_url in [
|
|
|
+ "file:C:/foo.bar/baz",
|
|
|
+ "file:/C:/foo.bar/baz",
|
|
|
+ "file://C:/foo.bar/baz",
|
|
|
+ "file:///C:/foo.bar/baz",
|
|
|
+ ]:
|
|
|
+ c, path = get_transport_and_path(file_url)
|
|
|
+ self.assertIsInstance(c, LocalGitClient)
|
|
|
+ self.assertEqual(path, expected)
|
|
|
+
|
|
|
+ for remote_url in [
|
|
|
+ "file://host.example.com/C:/foo.bar/baz"
|
|
|
+ "file://host.example.com/C:/foo.bar/baz"
|
|
|
+ "file:////host.example/foo.bar/baz",
|
|
|
+ ]:
|
|
|
+ with self.assertRaises(NotImplementedError):
|
|
|
+ c, path = get_transport_and_path(remote_url)
|
|
|
|
|
|
|
|
|
class TestSSHVendor:
|