There was an error while loading. Please reload this page.
1 parent 9807dd4 commit 7f08b77Copy full SHA for 7f08b77
2 files changed
git/repo/base.py
@@ -36,6 +36,11 @@
36
import gc
37
import gitdb
38
39
+try:
40
+ import pathlib
41
+except ImportError:
42
+ pathlib = None
43
+
44
45
log = logging.getLogger(__name__)
46
@@ -116,6 +121,8 @@ def __init__(self, path=None, odbt=GitCmdObjectDB, search_parent_directories=Fal
116
121
epath = decygpath(epath)
117
122
118
123
epath = epath or path or os.getcwd()
124
+ if not isinstance(epath, str):
125
+ epath = str(epath)
119
126
if expand_vars and ("%" in epath or "$" in epath):
120
127
warnings.warn("The use of environment variables in paths is deprecated" +
128
"\nfor security reasons and may be removed in the future!!")
git/test/test_repo.py
@@ -110,6 +110,14 @@ def test_repo_creation_from_different_paths(self, rw_repo):
110
assert not rw_repo.git.working_dir.endswith('.git')
111
self.assertEqual(r_from_gitdir.git.working_dir, rw_repo.git.working_dir)
112
113
+ @with_rw_repo('0.3.2.1')
114
+ def test_repo_creation_pathlib(self, rw_repo):
115
+ if pathlib is None: # pythons bellow 3.4 don't have pathlib
+ raise SkipTest("pathlib was introduced in 3.4")
+ r_from_gitdir = Repo(pathlib.Path(rw_repo.git_dir))
+ self.assertEqual(r_from_gitdir.git_dir, rw_repo.git_dir)
def test_description(self):
txt = "Test repository"
self.rorepo.description = txt
0 commit comments