Skip to content
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

parsePathFlakeRefWithFragment(): Handle 'path?query' without a fragment #12157

Conversation

edolstra
Copy link
Member

@edolstra edolstra commented Jan 8, 2025

Motivation

Commands like nix flake metadata '.?submodules=1' ignored the query part of the URL, while nix build '.?submodules=1#foo' did work correctly because of the presence of the fragment part.

Before:

$ nix flake metadata '.?submodules=1'
Resolved URL:  git+file:///home/eelco/Dev/nix

After:

$ nix flake metadata '.?submodules=1'
Resolved URL:  git+file:///home/eelco/Dev/nix?submodules=1

Context


Add 👍 to pull requests you find important.

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

Commands like `nix flake metadata '.?submodules=1'` ignored the query
part of the URL, while `nix build '.?submodules=1#foo'` did work
correctly because of the presence of the fragment part.
@edolstra edolstra added bug flakes backport 2.25-maintenance Automatically creates a PR against the branch labels Jan 8, 2025
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Jan 8, 2025
query = decodeQuery(url.substr(pathEnd + 1, fragmentStart - pathEnd - 1));
}
static std::regex pathFlakeRegex(
R"(([^?#]*)(\?([^#]*))?(#(.*))?)",
Copy link
Member

Choose a reason for hiding this comment

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

Do we have test cases for different urls?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added some unit tests (which revealed another bug).

@Mic92 Mic92 merged commit 2d9b213 into NixOS:master Jan 9, 2025
12 checks passed
@grahamc grahamc deleted the fix-path-flakeref-query-without-fragment branch January 9, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.25-maintenance Automatically creates a PR against the branch bug flakes with-tests Issues related to testing. PRs with tests have some priority
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants