| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e3f38ff commit 24abf10
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1362,8 +1362,10 @@ def _clone( | |||
| 1362 | 1362 | odbt = kwargs.pop("odbt", odb_default_type) | |
| 1363 | 1363 | ||
| 1364 | 1364 | # When pathlib.Path or other class-based path is passed | |
| 1365 | + if not isinstance(url, str): | ||
| 1366 | + url = url.__fspath__() | ||
| 1365 | 1367 | if not isinstance(path, str): | |
| 1366 | - path = str(path) | ||
| 1368 | + path = path.__fspath__() | ||
| 1367 | 1369 | ||
| 1368 | 1370 | ## A bug win cygwin's Git, when `--bare` or `--separate-git-dir` | |
| 1369 | 1371 | # it prepends the cwd or(?) the `url` into the `path, so:: | |
@@ -1380,7 +1382,7 @@ def _clone( | |||
| 1380 | 1382 | multi = shlex.split(" ".join(multi_options)) | |
| 1381 | 1383 | ||
| 1382 | 1384 | if not allow_unsafe_protocols: | |
| 1383 | - Git.check_unsafe_protocols(str(url)) | ||
| 1385 | + Git.check_unsafe_protocols(url) | ||
| 1384 | 1386 | if not allow_unsafe_options: | |
| 1385 | 1387 | Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=cls.unsafe_git_clone_options) | |
| 1386 | 1388 | if not allow_unsafe_options and multi_options: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | # This module is part of GitPython and is released under the | |
| 2 | 2 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ | |
| 3 | 3 | ||
| 4 | + from dataclasses import dataclass | ||
| 4 | 5 | import os | |
| 5 | 6 | import os.path as osp | |
| 6 | 7 | import pathlib | |
@@ -45,7 +46,20 @@ def test_checkout_in_non_empty_dir(self, rw_dir): | |||
| 45 | 46 | def test_clone_from_pathlib(self, rw_dir): | |
| 46 | 47 | original_repo = Repo.init(osp.join(rw_dir, "repo")) | |
| 47 | 48 | ||
| 48 | - Repo.clone_from(original_repo.git_dir, pathlib.Path(rw_dir) / "clone_pathlib") | ||
| 49 | + Repo.clone_from(pathlib.Path(original_repo.git_dir), pathlib.Path(rw_dir) / "clone_pathlib") | ||
| 50 | + | ||
| 51 | + @with_rw_directory | ||
| 52 | + def test_clone_from_pathlike(self, rw_dir): | ||
| 53 | + original_repo = Repo.init(osp.join(rw_dir, "repo")) | ||
| 54 | + | ||
| 55 | + @dataclass | ||
| 56 | + class PathLikeMock: | ||
| 57 | + path: str | ||
| 58 | + | ||
| 59 | + def __fspath__(self) -> str: | ||
| 60 | + return self.path | ||
| 61 | + | ||
| 62 | + Repo.clone_from(PathLikeMock(original_repo.git_dir), PathLikeMock(os.path.join(rw_dir, "clone_pathlike"))) | ||
| 49 | 63 | ||
| 50 | 64 | @with_rw_directory | |
| 51 | 65 | def test_clone_from_pathlib_withConfig(self, rw_dir): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments