libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.61k stars 385 forks source link

Abillity to clone git repository in non-empty folder [feature-request] #1075

Open rickstaa opened 3 years ago

rickstaa commented 3 years ago

When I try to clone a repository using the pygit2.clone_repository function, it keeps giving me a '.' exists and is not an empty directory error. I can solve this by appending a backward slash / to the pathstr. I, however, for my project, need to be able to clone multiple repositories next to each other inside a catkin workspace. There are several easy workarounds for this problem, but I wondered if this is supported out of the box. I think supporting this out of the box would be more in line with how the bash git client clones git repositories.

How to reproduce

  1. Run the following code in python.
import pygit2
repo_url = "https://bitbucket.org/theconstructcore/spawn_robot_tools.git"
pygit2.clone_repository(repo_url, ".", bare=True)
  1. See the not empty folder error.

Example work-around

import pygit2
repo_url = "https://bitbucket.org/theconstructcore/spawn_robot_tools.git"
pygit2.clone_repository(repo_url, "./"+repo_url.split("/")[-1].replace(".git", ""), bare=True)