Skip to content

run_external.rs: use pathdiff::diff_path to handle relative path#13056

Merged
WindSoilder merged 4 commits intonushell:mainfrom
WindSoilder:path_diff
Jun 7, 2024
Merged

run_external.rs: use pathdiff::diff_path to handle relative path#13056
WindSoilder merged 4 commits intonushell:mainfrom
WindSoilder:path_diff

Conversation

@WindSoilder
Copy link
Copy Markdown
Contributor

Description

This pr is going to use pathdiff::diff_path, so we don't need to handle for relative path by ourselves.

This is also the behavior before the rewritten of run_external.rs

It's a follow up to #13028

User-Facing Changes

NaN

Tests + Formatting

No need to add tests

@WindSoilder WindSoilder changed the title run_external.rs: use pathdiff::diff_path run_external.rs: use pathdiff::diff_path to handle relative path Jun 4, 2024
assert_eq!(actual, expected);

let actual = expand_glob("./*.txt", cwd, Span::unknown(), &None).unwrap();
let expected = vec![
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this test intentionally - it should include the ./, because if the user specified that in their glob, they probably expect it in the output.

devyn
devyn previously requested changes Jun 5, 2024
Copy link
Copy Markdown
Contributor

@devyn devyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think removing the test for ./*.txt[./a.txt ./b.txt] is incorrect - that should intentionally glob that way. Maybe we weren't doing that before though?

@WindSoilder
Copy link
Copy Markdown
Contributor Author

Maybe we weren't doing that before though?

No, we just remove ./*txt before. To be honest I think it doesn't matter if nushell removes ./ or not.

@devyn
Copy link
Copy Markdown
Contributor

devyn commented Jun 5, 2024

Sometimes it does matter - for example if you were trying to make an executable path. But I agree it usually doesn't

@devyn devyn dismissed their stale review June 5, 2024 06:45

I'm okay with whatever you decide - if this makes it easier then let's do it

@devyn
Copy link
Copy Markdown
Contributor

devyn commented Jun 5, 2024

...but it would be nice to have this in a utility function so we can reuse it.

@WindSoilder
Copy link
Copy Markdown
Contributor Author

...but it would be nice to have this in a utility function so we can reuse it.

Sure, It's a good advice! I added resolve_globbed_path_to_cwd_relative function, but yeah the name might be too long..

@WindSoilder WindSoilder merged commit 83cf212 into nushell:main Jun 7, 2024
@devyn
Copy link
Copy Markdown
Contributor

devyn commented Jun 7, 2024

I'm totally ok with long names if they're accurate 😄

@WindSoilder WindSoilder deleted the path_diff branch June 7, 2024 08:07
@hustcer hustcer added this to the v0.95.0 milestone Jun 7, 2024
@fdncred fdncred added the api-change This PR should be mentioned in #api-updates channel on Discord label Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-change This PR should be mentioned in #api-updates channel on Discord

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants