You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to clone a repository using Repo.clone_from() with a specific SSH key. This appears to be possible by setting GIT_SSH using custom_environment() on a Git instance. However, clone_from() appears to be creating its own Git instance so I am not able to create a custom environment in this case. Would I have to reimplement clone_from() to use a custom environment? Or is there some other way of working around this limitation that I am missing?
The text was updated successfully, but these errors were encountered:
Unfortunately you are not missing anything, the API currently does not allow control over the environment when clone_from() is invoked.
As **kwargs are already used for additional commandline parameters to the process, one might be tempted to add some special key, like env which contains the desired environment. It should be easy to implement, in case you feel like making another PR.
To get you started with an API change, I'd recommend just instantiating a git command directly (Git(os.getcwd())) and configure it to your liking to get the clone. From the resulting path, you should be able to instantiate a Repo and get going.
Alternatively, you could copy and adjust the _clone(...) method, but it might be more than you actually need. Most of its complexity stems from its ability to parse progress in real-time.
Please let me know if it works and/or what you think.
Thanks. I solved my problem by creating a Git instance, updating the environment and then calling clone() on that instance. I've opened a PR in #307 with your proposed env parameter.
I want to clone a repository using
Repo.clone_from()
with a specific SSH key. This appears to be possible by settingGIT_SSH
usingcustom_environment()
on aGit
instance. However,clone_from()
appears to be creating its ownGit
instance so I am not able to create a custom environment in this case. Would I have to reimplementclone_from()
to use a custom environment? Or is there some other way of working around this limitation that I am missing?The text was updated successfully, but these errors were encountered: