-
-
Notifications
You must be signed in to change notification settings - Fork 348
Accept ToComponents
in gix_fs::Stack
#1909
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
Accept ToComponents
in gix_fs::Stack
#1909
Conversation
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 for getting started on this, it's much appreciated!
- There’s places that currently call
Stack::new
with aPathBuf
. Would it make sense toimpl ToComponents for PathBuf
?
No - I have made some more comments in code with details.
- Having to add
bstr
as a dependency made me wonder: isgix-fs
the right crate forToComponents
to live in or should it be moved somewhere else, e. g. intogix-path
?gix-path
also hasos_string_into_bstring
which should probably replace the chain.as_os_str().as_bytes().into()
that I had to resort to on one line becausegix-fs
does not depend ongix-path
currently.
Indeed, I think gix-path
is the better spot for it. The reason is also that I think it will harbour the RepositoryPathBuf/RepositoryPath
one day, which will be the typed version of a BString
as we use it today.
The place where ToComponents
needs to go is make_relative_path_current()
and its callers. Then the callers have to be adjusted to avoid calls to gix::path::<conversion>
as these shouldn't be needed anymore.
I hope that helps.
gix-fs/src/lib.rs
Outdated
root: PathBuf, | ||
/// the most recent known cached that we know is valid. | ||
current: PathBuf, |
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.
These have to stay PathBuf
as the type is a link between relative paths and the filesystem location they represent.
It's also in the interest of performance to keep it close to what it ought to represent.
gix-fs/src/stack.rs
Outdated
impl Stack { | ||
/// Create a new instance with `root` being the base for all future paths we handle, assuming it to be valid which includes | ||
/// symbolic links to be included in it as well. | ||
pub fn new(root: PathBuf) -> Self { | ||
pub fn new(root: impl ToComponents) -> Self { |
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.
Since this is the root and it is a filesystem location, it must remain a PathBuf
.
ToComponents
is really only for the relative paths that are passed in.
It's interesting that ToComponents
currently doesn't convey information about whether the component is coming from a relative path, which kind of is a problem, but maybe one that can be tackled later.
I’m running into an issue when trying to turn Lines 103 to 111 in c8c42b4
|
I think the problem here is twofold:
To me this means the trait would have to be owned by Another conclusion here probably is that there will be many |
177cd5b
to
40e8e51
Compare
I hope what I just pushed is closer to your suggestions, even though the new trait |
5b7c771
to
788a7c7
Compare
Thanks a lot - this looks like it should work! @pascalkuthe Would helix be able to update their MSRV to something newer? |
34deb0b
to
3d8ad4d
Compare
I didn't quite get which MSRV version you are looking for. Is it 1.75? That would be fine for us. |
Yes, that’s the one.
Great!
|
3d8ad4d
to
0280e80
Compare
I’ve rebased and merged the commits, so now there’s only 2 left which definitely is a simplification. Before I randomly start changing callers, up to which level do we want to accept |
Feel free to take over! I’ve just marked this PR as ready and will have a look at the next item on your list of suggestions! |
Helix can follow.
d29a179
to
8de6128
Compare
7591f37
to
84e1049
Compare
84e1049
to
1f98edb
Compare
This changes `cargo check` commands to `cargo build` in the `ci-check-msrv` recipe in the `justfile`, which the `check-msrv` CI jobs in `msrv.yml` use. (It updates a CI step name accordingly.) The idea is to make sure at least `gix`, with the two combinations of features tested, actually *builds* under the MSRV toolchain. As in f10f18d, this also updates the `Makefile` rule corresponding to that `justfile` recipe. The idea of actually building was suggested in: GitoxideLabs#1808 (comment) However, this does not uncover any new breakages. And there has been further improvement on GitoxideLabs#1808, including in the commits leading up to this, as well as earlier, in 569c186 (GitoxideLabs#1909). Nonetheless, it seems likely that some problems remain with some combinations of crates and features that are not currently exercised in the MSRV check. GitoxideLabs#1808 is most likely not yet fully fixed.
This is a draft PR, intended to make sure I got the task right before making any larger changes that I would need to make now that I’ve changed
gix_fs::Stack
’s API. It is expected that it does not even compile at this stage.A few observations:
Stack::new
with aPathBuf
. Would it make sense toimpl ToComponents for PathBuf
?bstr
as a dependency made me wonder: isgix-fs
the right crate forToComponents
to live in or should it be moved somewhere else, e. g. intogix-path
?gix-path
also hasos_string_into_bstring
which should probably replace the chain.as_os_str().as_bytes().into()
that I had to resort to on one line becausegix-fs
does not depend ongix-path
currently.Let me know what you think!