diff --git a/AUTHORS b/AUTHORS index 98167ea7e..f95409077 100644 --- a/AUTHORS +++ b/AUTHORS @@ -23,5 +23,6 @@ Contributors are: -Ken Odegard -Alexis Horgix Chotard -Piotr Babij +-Mikuláš Poul Portions derived from other open source works and are clearly marked. diff --git a/git/repo/base.py b/git/repo/base.py index 9ed3f7141..6ee95aed9 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -905,6 +905,10 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs): odbt = kwargs.pop('odbt', odb_default_type) + # when pathlib.Path or other classbased path is passed + if not isinstance(path, str): + path = str(path) + ## A bug win cygwin's Git, when `--bare` or `--separate-git-dir` # it prepends the cwd or(?) the `url` into the `path, so:: # git clone --bare /cygwin/d/foo.git C:\\Work diff --git a/git/test/test_repo.py b/git/test/test_repo.py index 86fb2f51f..2c3ad9570 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -16,6 +16,11 @@ except ImportError: from unittest2 import skipIf, SkipTest +try: + import pathlib +except ImportError: + pathlib = None + from git import ( InvalidGitRepositoryError, Repo, @@ -210,6 +215,15 @@ def test_clone_from_keeps_env(self, rw_dir): assert_equal(environment, cloned.git.environment()) + @with_rw_directory + def test_clone_from_pathlib(self, rw_dir): + if pathlib is None: # pythons bellow 3.4 don't have pathlib + raise SkipTest("pathlib was introduced in 3.4") + + original_repo = Repo.init(osp.join(rw_dir, "repo")) + + Repo.clone_from(original_repo.git_dir, pathlib.Path(rw_dir) / "clone_pathlib") + def test_init(self): prev_cwd = os.getcwd() os.chdir(tempfile.gettempdir())