-
-
Notifications
You must be signed in to change notification settings - Fork 394
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
Add in doco examples for how to clone a remote repo using a proxy #1328
Comments
Can you describe what you're trying to accomplish in more detail? If your problem is about the proxy's username/pass, shouldn't that be part of the proxy's URL? proxy = f"http://{USER}:{PASS}@proxy.example.org:3128" |
Hey, We can't talk to github.com unless we go via an authed proxy and we were unable to get pygit2 to work. We did try examples like this - but when running it we couldn't even see the attempt going out via a proxy it was still trying to go direct. Its still very possible we were doing things wrong, but other parts of the code were honoring both the proxy from the https_proxy env vars and the manually set ones in code. We have pivoted and coding things differently to get around this, but having a real working example in what I linked would help future users. if they hit the same issues. I don't need this issue open anymore, so if there's no value seen then it may be closed. |
@davidcba1 There is currently no one-line way to clone thru a proxy. I've created #1354 for this. In the meantime, you can use something like: from pygit2 import Commit, init_repository
from pygit2.enums import ResetMode
url = "https://github.com/libgit2/TestGitRepository"
dest = "TestGitRepository"
main_branch = "master"
repo = init_repository(dest, initial_head=main_branch, origin_url=url)
repo.remotes["origin"].fetch(proxy=True)
main_commit = repo.branches[f"origin/{main_branch}"].peel(Commit)
repo.branches.create(main_branch , main_commit)
repo.reset(main_commit.id, ResetMode.HARD) |
Hey,
I'm trying to work out how to use pygit2 to clone a remote repo using a proxy, i'm looking at some of the examples and I need to define a username/password which is fine but I can't work out how to use the proxy setting as well.
I'm referencing the following articles, but going around in circles
This one for user/pass
https://www.pygit2.org/recipes/git-clone-ssh.html
This one for remotes
https://www.pygit2.org/recipes/git-clone-mirror.html
and in the doco these bits
https://www.pygit2.org/remotes.html#pygit2.Remote.connect
https://www.pygit2.org/repository.html#pygit2.clone_repository
So this is 1 asking for guidance, but also a "recipe" for how to do this for future users.
The text was updated successfully, but these errors were encountered: