-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
Consumer config confusion #1125
Comments
I'll be happy to address these issues once we have an idea of what scope the change should be. |
Thanks a lot for this collection of issues - I am glad you did it as config is always a little bit neglected until the is an external stimulus for improvements, apparently 😅.
That could indeed be done once concrete tasks emerge, which could then be tackled one at a time. I'd expect most tasks be related to how About: Section/subsection confusionrepo.snapshot_mut().set_value(&Gitoxide::Credentials::TERMINAL_PROMPT, "false").unwrap(); This should work and the issue is addressed in the sibling-PR.
Yes, that's what it is there for. One could argue that maybe there are more intuitive ways to do this. But in general, keys need to be configured to work with it. So at the very least, the name of the method could change to clearly express that the subsection isn't 'statically' known. I think once there is a more general concept on how to use the static key hierarchy, this could be made so there is no such distinction at all. I can imagine to not even use About: Snapshot/SnapshotMut confusionProbably that issue would go away once The goal here would be to either not be forced to override anything in Of course it would be best if About: Expectation
I think having a separate method for subsections shouldn't even be necessary and would hope that an actual About: Suggested new interface
The Parameterizing the return value wasn't nice to use at all, and is present in
I agree that in order to prevent Conclusion/Next StepsYes, this can be improved and I have made a few suggestions on top of the ones presented here. Ideally, there is a way to have a convenient API in Becoming API-complete to have a 1:1 match with
Thanks! I wrote a lot and maybe some of it 'clicks' or seems useful enough to go with it. Please let me know what you think. |
Sorry for the silence. I'm thinking that the first step is to incrementally clean up the public interface of |
How about these as first steps:
I think we agree that "the gix config crate" |
Making the config-tree available as plumbing seems like a good idea! Having less code in With
This is a bit vague but I agree that generally attribute access is involved and cumbersome. Thus far I was unable to make it better, but also didn't find that the complexity is accidental. The uncontested next step would then be the creation of a new I believe that this should not be done by depending on |
I see. So That sort of implies that the On the crate name, is the tree "aspect" worth emphasizing in this new crate? (I'll make a draft PR on a new crate essentially containing |
Yes, it would implement that trait and it probably needs one specific error type which can also be obtained from the
That's a good catch! I'd avoid the extra complexity though and put a foot down, claiming that
I love that crate name!
Awesome, thanks so much for your help! |
There is now a draft pull request #1153 setting up a new |
These keys are not used at the moment, but will be introduced as part of the work performed under GitoxideLabs#1125.
I'm well into an implementation where the gix-config crate exports a Key trait that you implement to interact with its API. This appears to be going reasonably well, but I realized gix-submodule uses gix-config to parse the .gitmodules file, which would then need to have its own Key implementation or share the implementation with gix . At the moment, I'm leaning towards kicking the can down the road by having gix-config providing a plain/generic key implementation. Opinions? |
That's great to hear and I am looking forward to taking a look once you are ready.
The way I imagined the |
Well, I'm thinking that gix will still want to provide its own validating and documentation-friendly hierarchy of typed keys, so implementing |
That's how
I don't think parsing speed for these keys matters at all. It's my guess that before this shows up in the profile, everything else shows up before, particularly allocations. Did you know that this implemetnation of So I wouldn't worry about it and keep everything working as is. There also is a dedicated Key struct already which I think you meant, but I didn't 'read' it that way if that makes sense. I hope that helps, and thanks again for tackling this! |
Current behavior 😯
After #1093 I tried to integrate this new feature into my gitops tool, but concluded that when depending on Gitoxide as a library dependency, the config interface is a bit confusing. This issue collects my observations so far. Feel free to say it should be split into multiple issues, but I suspect that part of the fix is to change the API, which would needs to be established first. It is possible that the various issues reported here should simply be added to the #467 task list and discussion should continue there?
Section/subsection confusion
It seems that this snipet sets
credentials.terminalPrompt
:Not sure how
set_subsection_value
is supposed to be used, but it seems unusable for setting values in subsections? All these fail withSubSectionForbidden
. (I suppose the method was introduces for those cases where the subsection is e.g. a branch name or similar?)Snapshot/SnapshotMut confusion
Snapshot boolean accessor is
but SnapshotMut boolean accessor is
There seems to be no accessors that take
'static dyn Key
. (Possibly,Key
could be made to implementInto<&Bstr>
.)Expected behavior 🤔
Expectations on current interface
I would have expected
to deactivate terminal prompting by setting
gitoxide.credentials.terminalPrompt
. I would also have expected the API to encourage usingKey
s as much as possible for type safety.I would also have expected the
set_subsection_value
to be able to set values in ordinary "static" subsections.Suggested new Interface
As a lib consumer, I think that I would prefer the
Snapshot
to expose just:Symmetrical methods for "add" and "free" are presumably needed. The
Additionally, some sort of traversal API would be needed, e.g.
iter_keys
(oriter_values
or perhapsiter_entries
).In this marvelous world, there would be a
impl Into<Key<K>> for &BStr
andimpl Into<Key<K>> for &str
so that you can just pass in data you received from the user without sacrificing type safety. Presumably, the caller would have to construct a key instance for e.g. thebranch.<name>.remote
subsection by passing in the name.I suspect that
gix
the command needs at least some of the various methods that exist today, so it might be reasonable to either have a sub-trait for either case, or perhaps two accesseor methodsconfig_snapshot(_mut)
andconfig_???_snapshot(_mut)
.Git behavior
When considering a new API,
git-config
reports the following actions:Steps to reproduce 🕹
The text was updated successfully, but these errors were encountered: