Skip to content

clone_from() with custom environment #306

Closed

Description

@jonls

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?

Activity

  1. added this to the v1.0.2 - Fixes milestone on Jun 30, 2015
  2. Byron commented on Jun 30, 2015

    @Byron
    Member

    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.

  3. jonls commented on Jun 30, 2015

    @jonls
    Author

    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.

  4. Byron commented on Jul 1, 2015

    @Byron
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions