Skip to content

Comments

Cleanup isInDir and isDirOrInDir#12667

Merged
Ericson2314 merged 3 commits intomasterfrom
in-dir-cleanup
Mar 19, 2025
Merged

Cleanup isInDir and isDirOrInDir#12667
Ericson2314 merged 3 commits intomasterfrom
in-dir-cleanup

Conversation

@Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Mar 17, 2025

Motivation

See each commit for details.

Context

#9205


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

{
auto p1 = isInDir("/zes/foo/bar", "");
ASSERT_EQ(p1, true);
ASSERT_EQ(p1, false);
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should throw an exception, but returning false also seems safe.

TEST(isDirOrInDir, relativePathsTwice)
{
ASSERT_EQ(isDirOrInDir("/foo/..", "/foo/."), true);
ASSERT_EQ(isDirOrInDir("/foo/..", "/foo/."), false);
Copy link
Member

Choose a reason for hiding this comment

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

Idem, perhaps relative paths should throw an exception. I think there is an implicit assumption that isDirOrInDir() is called on absolute/canonicalized paths.

The behavior *does* change, per the tests, but I think the new behavior
is less buggy.
Because of the previous commit, we need to use `std::filesystem::path`
anyways.
@Ericson2314 Ericson2314 enabled auto-merge March 19, 2025 21:23
@Ericson2314 Ericson2314 merged commit 3d333e0 into master Mar 19, 2025
23 of 24 checks passed
@Ericson2314 Ericson2314 deleted the in-dir-cleanup branch March 19, 2025 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants