Skip to content

fetchTree: apply Git defaults consistently to URL and attribute inputs - #16428

Open
wangyusheng1985 wants to merge 1 commit into
NixOS:masterfrom
wangyusheng1985:repo-agent/2f4423bd-12860
Open

fetchTree: apply Git defaults consistently to URL and attribute inputs#16428
wangyusheng1985 wants to merge 1 commit into
NixOS:masterfrom
wangyusheng1985:repo-agent/2f4423bd-12860

Conversation

@wangyusheng1985

Copy link
Copy Markdown

Summary

builtins.fetchTree applied its documented Git shallow = true default only to attribute-set arguments. A direct git+... URL therefore exposed different metadata than the equivalent result of builtins.parseFlakeRef.

Move default handling after argument normalization so both representations receive identical Git defaults. Explicit shallow values and builtins.fetchGit behavior remain unchanged.

Add a functional regression test comparing the complete result sets and document the equivalence.

Validation

  • Built the patched Nix CLI and generated manual.
  • Ran the compiled fetchGit functional test.
  • Ran repository formatting and lint checks.

Closes: #12860

Automation disclosure

This patch and pull request draft were prepared with Claude Code (model unspecified) and require human review before submission.

Validation observed for this change:

  • docker run --rm --mount type=bind,src=/workspace/repository,dst=/src,readonly -w /src nixos/nix@sha256:cf7393e408da5ad343dad43670be72d7ee062b2a6a687990e9613ef9dc8bf2f6 nix build --no-link --print-build-logs --extra-experimental-features 'nix-command flakes' 'path:/src#nix-cli' 'path:/src#nix-manual'
  • docker run --rm --mount type=bind,src=/workspace/repository,dst=/src,readonly -w /src nixos/nix@sha256:cf7393e408da5ad343dad43670be72d7ee062b2a6a687990e9613ef9dc8bf2f6 nix build --no-link --print-build-logs --impure --extra-experimental-features 'nix-command flakes' --expr 'let flake = builtins.getFlake "path:/src"; package = flake.packages.x86_64-linux.nix-functional-tests; in package.overrideAttrs (old: { mesonCheckFlags = (old.mesonCheckFlags or []) ++ [ "fetchGit" ]; })'
  • docker run --rm --mount type=bind,src=/workspace/repository,dst=/src,readonly -w /src nixos/nix@sha256:cf7393e408da5ad343dad43670be72d7ee062b2a6a687990e9613ef9dc8bf2f6 nix build --no-link --print-build-logs --extra-experimental-features 'nix-command flakes' 'path:/src#checks.x86_64-linux.pre-commit'

Fixes #12860

Keep URL-like and parsed inputs equivalent by applying the shallow default after normalization.

Assisted-by: Claude Code (model unspecified)
Signed-off-by: wangyusheng1985 <wangyusheng1985@users.noreply.github.com>
@github-actions github-actions Bot added the with-tests Issues related to testing. PRs with tests have some priority label Sep 4, 2026
@wangyusheng1985
wangyusheng1985 marked this pull request as ready for review September 4, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

builtins.fetchTree behaves differently if uri or attrs are parsed

1 participant