Skip to content

clone_from() with custom environment #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jonls opened this issue Jun 29, 2015 · 3 comments
Closed

clone_from() with custom environment #306

jonls opened this issue Jun 29, 2015 · 3 comments

Comments

@jonls
Copy link
Contributor

jonls commented Jun 29, 2015

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?

@Byron Byron added this to the v1.0.2 - Fixes milestone Jun 30, 2015
@Byron
Copy link
Member

Byron commented Jun 30, 2015

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.

@jonls
Copy link
Contributor Author

jonls commented Jun 30, 2015

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.

@Byron
Copy link
Member

Byron commented Jul 1, 2015

Thanks again - it's merged now and you should fix this issue too.

Feel free to close it if this is indeed the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants