-
Notifications
You must be signed in to change notification settings - Fork 10
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
Feat globs can be relative for newglob and cli arg #79
Feat globs can be relative for newglob and cli arg #79
Conversation
Globs are now normalized and can be relative
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.
Excellent work man, thanks a lot for this. I'm happy with it as it is.
…/riv into normalize-and-relative-paths
Relative paths do not work on Windows. I'll get some screenshots shortly. |
@gurgalex okay sweet, I wonder what's going wrong on that end. 🤔 |
I can confirm that the development branch resolves |
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.
@NickHackman Do you have access to windows machine to try to resolve this, or can you figure it out together with @gurgalex?
@gurgalex @Davejkane hmm, I have no idea what would be causing that. I'll setup a windows VM and I'll try testing things out, I'll get back to you guys later tonight on the state of this. Edit: Working on this more tomorrow |
@NickHackman "some" test cases for Windows though... (search for tc! |
* Stopped using std::fs::canonicalize in favor of a custom implementation, because std::fs::canonicalize requires paths to exist and therefore all globs fail
@Davejkane Sorry that took so long, I've had other stuff come up (I'm in summer semester and in a project class). @gurgalex I tried really hard to use |
@NickHackman Small issue with path escaping on Linux (Windows testing soon) With the directory |
Okay I see, that is a rough edge case... So the solution would be to replace all escaped things with the thing that's being escaped. I'll get back to you shortly on that! Maybe a regex replace would be able to do that. Thanks @gurgalex that's a really good test case I appreciate it edit: formatting |
* Before only escaped spaces were covered, but now all escape sequences are properly evaluated.
Okay cool, @gurgalex that now works as expected, thanks again. It also works for stuff like Anything wrong on the Windows side? There shouldn't be afaik. Edit: Disregard me below being really bad at merging |
@NickHackman It seems like you had at least one earlier? |
@gurgalex I think we need test cases for everything, I've recently switched to a TDD mindset, but it's really hard to test things at the OS level. I think we should follow Exa that uses Vagrant Furthermore, are we doing just public facing method testing or are we doing private methods as well? @Davejkane Edit: Yeah good, idea |
I agree, I at least am testing things that don't rely on the OS in the refactor and implementation of #48 |
Edited to add glob pattern path You could test the output of the path returned. Example. This works on linux. use std::path::PathBuf;
fn main() {
let path = PathBuf::from(r"C:\windows\system32/*.dll");
dbg!(&path);
assert_eq!(path, PathBuf::from(r"C:\windows\system32/*.dll"));
} |
Yeah, globs would be harder. |
Yeah, oddly enough... This test case fails when running on Unix #[test]
fn normalize_path_prefix_windows() {
let path = PathBuf::from(r"C:\windows\.");
assert_eq!(normalize_path(path), PathBuf::from(r"C:\windows"));
} Which is really weird, since the Unix alternative passes? Also pretty sure this functions on windows as well... |
@NickHackman & @gurgalex, I'd definitely be interested in getting some more testing in this project. It kinda just started as way to scroll through some pictures. But it's definitely time for a bit more professionalism now that it's coming together as a piece of software. @NickHackman What's the status of this branch? Are you happy with it now, or are there still unresolved things? |
@Davejkane I'm happy with the state of this branch. There isn't anything unresolved 😃 As we discussed above I have Unix test cases if you want (since all Windows test cases will fail on a Unix machine and vice versa) if you'd like those I can push those onto this PR, but they will fail on the opposite platform... as a result of how Rust |
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.
@NickHackman this looks great. Thanks a lot, it wasn't something I had thought of, but I'm impressed with your eye for correctness in the small details. Please squash and merge when you can and tidy up the commit message to be only info relevant to the final state of the PR (so nothing about fmt and stuff like that.)
@Davejkane I'm still new to this, so maybe I'm just confused, but don't I need write access? |
@NickHackman yeah, you're right. I'll do the merge. |
Relative paths now work for both the command line argument and newglob
Example:
Starting in directory
~/Code/riv
you can run$ riv "../../Pictures/**/*"
which will display all pictures in~/Pictures
:ng ~/Pictures
then:ng copied_images
then back again:ng ..
Paths are now normalized removing "."s and ".."s
Example:
$ riv "~/Pictures/././././../Pictures/"
results in~/Pictures
Removal of escaped spaces is now ONLY done for Unix and not for Windows
using
cfg!(unix)