Comments (13)
Ah, yes, I see, it was changed in November. In that case:
var cloneOptions = new CloneOptions();
cloneOptions.FetchOptions.CredentialsProvider = ...
should work, no?
(It looks like @mburtka was complaining about not being able to new up a FetchOptions
- but I don't have any insight into the API design here.)
from libgit2sharp.
Right, like I said, I don't have any insight into the rationale here. I don't know if @bording would be willing to review a PR here to change this back to have a setter, or if there's a philosophical or architectural reason to keep it readonly?
This was an intentional change on my part, primarily around the fact that I wanted to guard against the FetchOptions
property from ever being null
. I don't like APIs that have you create a type (CloneOptions
in this case) that require you to create a new instance of a object, but then also require you to create instances of other nested types to actually make the original object valid.
That was why when I moved FetchOptions
into a property of CloneOptions
instead of how it was previously combining the various properties together, I decided to ensure the creation of the CloneOptions
would also create the FetchOptions
for it. And since an instance has been created for you, you would then set the individual options from the property as @ethomson demonstrated in #2075 (comment).
from libgit2sharp.
As mentioned in the change log, there were some breaking changes to CloneOptions
as part of adding proxy support.
CredentialsProvider
can now be found on the FetchOptions
property on CloneOptions
.
from libgit2sharp.
As mentioned in the change log, there were some breaking changes to
CloneOptions
as part of adding proxy support.
CredentialsProvider
can now be found on theFetchOptions
property onCloneOptions
.
from this explanation, it is not clear at all what changes should be made. If you look at FetchOptions now, you won't see anything similar to CredentialsProvider there. Documentation, for example git-clone , immediately became useless.. Great, everything is very clear.... (no)
from libgit2sharp.
As mentioned in the change log, there were some breaking changes to
CloneOptions
as part of adding proxy support.
CredentialsProvider
can now be found on theFetchOptions
property onCloneOptions
.
The breaking change makes sense to me, but what was the rationale behind making the FetchOptions
property on CloneOptions
read only? I have a specific way of newing up FetchOptions
in my app and not being able to assign means I'd have to change that logic to operate on an existing instance.
Do you have any opposition to exposing that either via setter or ctor? I'd be happy to submit a PR.
from libgit2sharp.
I too am utterly confused by this change. Previously, I was creating a CloneOptions and setting CredentialsProvider in there. I can create a FetchOptions instead and set the credentials, but can't find any way to pass this into CloneOptions.
Please can someone share a fix? I'm passing in the credentials because the call failed without them.
from libgit2sharp.
@gwsutcliffe Does this work?
Repository.Clone("https://github.com/libgit2/TestGitRepository", "/tmp/testgitrepository",
new CloneOptions {
FetchOptions = {
CredentialsProvider = ...
}
});
from libgit2sharp.
FetchOptions is read only (see the comment by mburtka above). This is the problem - your solution would be fine if FetchOptions could be set (and I wouldn't be posting here).
I've rolled back to v0.28 for now so as not to break my application's functionality.
from libgit2sharp.
Ah, yes, I see, it was changed in November. In that case:
var cloneOptions = new CloneOptions(); cloneOptions.FetchOptions.CredentialsProvider = ...
should work, no?
That does work, but I had a factory method to new up my customized `FetchOptions' using credentialing defined at startup. To upgrade I have to update that to operate on an existing instance:
var cloneOptions = new CloneOptions();
_fetchOptionsManager.Populate(cloneOptions.FetchOptions);
Instead of just newing up the FetchOptions
with the CloneOptions
. While it does work, it's ugly and is counter to all the other get/set behavior of the API.
from libgit2sharp.
Instead of just newing up the FetchOptions with the CloneOptions. While it does work, it's ugly and is counter to all the other get/set behavior of the API.
Right, like I said, I don't have any insight into the rationale here. I don't know if @bording would be willing to review a PR here to change this back to have a setter, or if there's a philosophical or architectural reason to keep it readonly?
from libgit2sharp.
@bording would you be amenable to having a constructor with either a null guard using the Ensure
class used elsewhere or a coalesce-assign?
I new up my FetchOptions
using a factory injected at startup (with credentialing, prune settings, etc..) and would prefer to keep that logic in the factory. But if you don't want to go that route I understand.
from libgit2sharp.
Just creating links for the other issues by people facing the same issue.
#2087
#2088
To set the credentials correctly, see: #2075 (comment)
from libgit2sharp.
Related Issues (20)
- Unable to clone git repo while using this library. HOT 9
- `LibGit2SharpException` when cloning repository within a Docker container HOT 9
- Running libgit2sharp on Ubuntu 22.04 Arm64 got `LibGit2Sharp.LibGit2SharpException: the SSL certificate is invalid` HOT 12
- Getting exception "too many redirects or authentication replays" HOT 2
- ObjectDatabase.Write<T>(Stream stream...) overload does not respect T
- .NET Standard support? HOT 4
- Unable to push to Azure DevOps repository when project name contains space HOT 1
- Performance regression when reading files from the tree in parallel HOT 6
- Security: Update to libgit2 1.7.2 HOT 3
- unexpected EOF when trying to fetch from remote
- Please consider adding AOT support for .Diff.Compare<T>() HOT 19
- How to checkout a specific folder from repository?
- LibGit2SharpException: could not find appropriate mechanism for credentials HOT 5
- FetchOptions in CloneOptions is readonly and has not been set in constructor !
- Git Fetch fails with could not decrypt tls message when TLS 1.3 is allowed
- git 2.40.0 index.skipHash incompatible with libgit2sharp (please update libgit2 from 1.7.1 to 1.8.0)
- the command pull take the class Repository instead of the interface like other commands
- Security Vulnerabilities in git2-106a5f2.dll: Non-Compliance with Secure Hashing and Compiler Security Best Practices HOT 2
- Request - upgrade to libgit2 1.7.2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libgit2sharp.