-
-
Notifications
You must be signed in to change notification settings - Fork 328
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
Allow configuting the Repository object created by PrepareFetch #1141
Conversation
Thanks for bringing this up and for the initial analysis! It's great to go straight to PR with the preferred option as it's much more visual that way. Something I currently find cumbersome is error handling in closures, as one is forced to go down to However, I think a current solution could be to ask for an iterator of command-overrides to pass to Would that be enough for your use-case? |
Maybe it's a bit much to have to deal with two work-streams at the same time. If so, please feel free to close this PR and reopen once there is more time. |
e895fef
to
9833b45
Compare
Not at all. Just had to work around some limitations in the dependent app. I used the name Any way, in the dependent app, it looks like this: let repo = gix::prepare_clone(url, target)
.unwrap()
.config_overrides(vec!["gitoxide.credentials.terminalPrompt=false"])
.fetch_only(Discard, &watchdog)
.map(|(r, _)| r)?; Config parse errors are not emitted until you fetch, which is a bit of a wart, but probably a minor one since in 9 cases out of 10, you will do both at the same time like the above example. |
That's true, but it's supposed to be used like like here in |
With it one can affect the repository configuration right before fetching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! This looks just like I imagined it :)!
And yes, a lot has to happen to make builders consistent, and further to change the API surface so that it can be stabilized. Right now, there are many open options structs that will break the API with each new addition. Further, each error enum technically breaks the API each time a new variant is added.
In any case, I have made minor adjustments, added a test, and will merge when CI is green.
Nice 👍 Sorry about missing test cases; for some reason I looked for tests only inside |
In the process of implementing terminal prompt configuration (see #1093) I cannot find a way to apply this configuration when using
gix::prepare_clone()
, that is, before calling.fetch_only()
. There seems to be two alternatives to this:Remote::repo_mut()
method so that you can doremote.repo().config_snapshot_mut()
inPrepareFetch::configure_remote()
PrepareFetch::configure()
method which gives access to a&mut SnapshotMut<'_>
objectI don't like the first solution. You are supposed to have recevied the
Remote
from aRepository
and you should be able to do configuration from there. To my understanding theconfigure_{remote,transport}
methods exist because you can do advanced stuff with the respective object that is not directly coverend by cofngiration.I'm not too fond of the second option either (not least because there would be three different configuration methods on
PrepareFetch
), but I created this pull request to point out that there is currently no way to perform such configuration.(You may of course claim that
gix::prepare_clone
is a convenience method and that if you need to configure your repo, you should init an empty repo and fetch into it.)