Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4dd14b6

Browse files
authored
Merge pull requestgitpython-developers#685 from mikicz/pathlib-clone
Converting path in _clone to str before any other operation
2 parents66328d7 +4ee7e1a commit4dd14b6

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

‎AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ Contributors are:
2323
-Ken Odegard <ken.odegard _at_ gmail.com>
2424
-Alexis Horgix Chotard
2525
-Piotr Babij <piotr.babij _at_ gmail.com>
26+
-Mikuláš Poul <mikulaspoul _at_ gmail.com>
2627

2728
Portions derived from other open source works and are clearly marked.

‎git/repo/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,10 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs):
905905

906906
odbt=kwargs.pop('odbt',odb_default_type)
907907

908+
# when pathlib.Path or other classbased path is passed
909+
ifnotisinstance(path,str):
910+
path=str(path)
911+
908912
## A bug win cygwin's Git, when `--bare` or `--separate-git-dir`
909913
# it prepends the cwd or(?) the `url` into the `path, so::
910914
# git clone --bare /cygwin/d/foo.git C:\\Work

‎git/test/test_repo.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
exceptImportError:
1717
fromunittest2importskipIf,SkipTest
1818

19+
try:
20+
importpathlib
21+
exceptImportError:
22+
pathlib=None
23+
1924
fromgitimport (
2025
InvalidGitRepositoryError,
2126
Repo,
@@ -210,6 +215,15 @@ def test_clone_from_keeps_env(self, rw_dir):
210215

211216
assert_equal(environment,cloned.git.environment())
212217

218+
@with_rw_directory
219+
deftest_clone_from_pathlib(self,rw_dir):
220+
ifpathlibisNone:# pythons bellow 3.4 don't have pathlib
221+
raiseSkipTest("pathlib was introduced in 3.4")
222+
223+
original_repo=Repo.init(osp.join(rw_dir,"repo"))
224+
225+
Repo.clone_from(original_repo.git_dir,pathlib.Path(rw_dir)/"clone_pathlib")
226+
213227
deftest_init(self):
214228
prev_cwd=os.getcwd()
215229
os.chdir(tempfile.gettempdir())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp