mirror of
https://github.com/NixOS/nix
synced 2025-07-07 06:01:48 +02:00
Fix missing file error messages from 'import'
This commit is contained in:
parent
5b079073c1
commit
1564c8f9d9
2 changed files with 23 additions and 2 deletions
|
@ -23,6 +23,12 @@ struct MountedSourceAccessorImpl : MountedSourceAccessor
|
|||
return accessor->readFile(subpath);
|
||||
}
|
||||
|
||||
Stat lstat(const CanonPath & path) override
|
||||
{
|
||||
auto [accessor, subpath] = resolve(path);
|
||||
return accessor->lstat(subpath);
|
||||
}
|
||||
|
||||
std::optional<Stat> maybeLstat(const CanonPath & path) override
|
||||
{
|
||||
auto [accessor, subpath] = resolve(path);
|
||||
|
|
|
@ -14,6 +14,8 @@ cat > "$repo/flake.nix" <<EOF
|
|||
x = 1;
|
||||
y = assert false; 1;
|
||||
z = builtins.readFile ./foo;
|
||||
a = import ./foo;
|
||||
b = import ./dir;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
@ -32,11 +34,24 @@ expectStderr 1 nix eval "git+file://$repo?ref=master#y" | grepQuiet "at «git+fi
|
|||
|
||||
expectStderr 1 nix eval "$repo#z" | grepQuiet "error: path '/foo' does not exist in Git repository \"$repo\""
|
||||
expectStderr 1 nix eval "git+file://$repo?ref=master#z" | grepQuiet "error: '«git+file://$repo?ref=master&rev=.*»/foo' does not exist"
|
||||
expectStderr 1 nix eval "$repo#a" | grepQuiet "error: path '/foo' does not exist in Git repository \"$repo\""
|
||||
|
||||
echo foo > "$repo/foo"
|
||||
echo 123 > "$repo/foo"
|
||||
|
||||
expectStderr 1 nix eval "$repo#z" | grepQuiet "error: File 'foo' in the repository \"$repo\" is not tracked by Git."
|
||||
expectStderr 1 nix eval "$repo#a" | grepQuiet "error: File 'foo' in the repository \"$repo\" is not tracked by Git."
|
||||
|
||||
git -C "$repo" add "$repo/foo"
|
||||
|
||||
[[ $(nix eval --raw "$repo#z") = foo ]]
|
||||
[[ $(nix eval --raw "$repo#z") = 123 ]]
|
||||
|
||||
expectStderr 1 nix eval "$repo#b" | grepQuiet "error: path '/dir' does not exist in Git repository \"$repo\""
|
||||
|
||||
mkdir -p $repo/dir
|
||||
echo 456 > $repo/dir/default.nix
|
||||
|
||||
expectStderr 1 nix eval "$repo#b" | grepQuiet "error: File 'dir' in the repository \"$repo\" is not tracked by Git."
|
||||
|
||||
git -C "$repo" add "$repo/dir/default.nix"
|
||||
|
||||
[[ $(nix eval "$repo#b") = 456 ]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue