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

Commit36bd3ba

Browse files
committed
Allow Pythlike paths when creating a git repo
1 parentad1ae5f commit36bd3ba

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

‎git/repo/base.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def __init__(
223223

224224
epath=epathorpathoros.getcwd()
225225
ifnotisinstance(epath,str):
226-
epath=str(epath)
226+
epath=epath.__fspath__()
227227
ifexpand_varsandre.search(self.re_envvars,epath):
228228
warnings.warn(
229229
"The use of environment variables in paths is deprecated"

‎test/test_repo.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6+
fromdataclassesimportdataclass
67
importgc
78
importglob
89
importio
@@ -105,6 +106,18 @@ def test_repo_creation_pathlib(self, rw_repo):
105106
r_from_gitdir=Repo(pathlib.Path(rw_repo.git_dir))
106107
self.assertEqual(r_from_gitdir.git_dir,rw_repo.git_dir)
107108

109+
@with_rw_repo("0.3.2.1")
110+
deftest_repo_creation_pathlike(self,rw_repo):
111+
@dataclass
112+
classPathLikeMock:
113+
path:str
114+
115+
def__fspath__(self)->str:
116+
returnself.path
117+
118+
r_from_gitdir=Repo(PathLikeMock(rw_repo.git_dir))
119+
self.assertEqual(r_from_gitdir.git_dir,rw_repo.git_dir)
120+
108121
deftest_description(self):
109122
txt="Test repository"
110123
self.rorepo.description=txt

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp