Skip to content
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 proxy options #2065

Merged
merged 9 commits into from
Dec 3, 2023
Merged

Add proxy options #2065

merged 9 commits into from
Dec 3, 2023

Conversation

bording
Copy link
Member

@bording bording commented Nov 26, 2023

This PR adds a ProxyOptions class that can be used to specify proxy options to all of the relevant places where a proxy could be needed.

ProxyType is set to Auto by default, so LibGit2Sharp will now respect any proxy settings configured in git. ProxyType can be set to None to disable using the repo's proxy settings. Specified let's you specify a a proxy URL. There are also callbacks to deal with credentials and certificate verification.

As part of these changes, CloneOptions and SubmoduleUpdateOptions have been updated to have all fetch-related options be exposed via a FetchOptions property and not a confusing mix of some being directly on the class and others being only in an existing FetchOptions property.

I haven't added any proxy-specific automated tests here primarily because I don't currently know of a good way to have a proxy server spun up in GitHub Actions that I can reliably use on all platforms that need to be tested on.

For now, the manual testing I've done will have to be enough!

@JonWillis-Tote
Copy link

JonWillis-Tote commented Jan 31, 2024

Hi, This was my previous code, but this PR as mentioned is breaking.
Is there documentation on how to use the new proxy feature so it works

 var cloneOptions = new CloneOptions();
 var usernamePasswordCredentials = new UsernamePasswordCredentials { Username = _githubOptions.Username, Password = _githubOptions.Token };
 cloneOptions.CredentialsProvider = (_url, _user, _cred) => usernamePasswordCredentials;
 Repository.Clone("https://github.com/Jon/MyRepo.git", directory, cloneOptions);

As CredentialsProvider has been removed, I did try replacing it with this, but it failed.

cloneOptions.FetchOptions.ProxyOptions.CredentialsProvider = (_url, _user, _cred) => usernamePasswordCredentials;
LibGit2Sharp.LibGit2SharpException: 'remote authentication required but no callback set'

Edit, Solved it. Given this change was about a proxy, i used ProxyOptions, but it turns out I didn't need it after all.

cloneOptions.FetchOptions.CredentialsProvider = (_url, _user, _cred) => usernamePasswordCredentials;

bgrainger added a commit to Faithlife/FaithlifeBuild that referenced this pull request Jul 11, 2024
See libgit2/libgit2sharp#2065 for details of the breaking changes.
SIkebe added a commit to SIkebe/gitbucket-utility that referenced this pull request Aug 20, 2024
SIkebe added a commit to SIkebe/gitbucket-utility that referenced this pull request Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants