-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The git fetcher is now more tree-hash-oriented, and we will want to integrate this with git fetching eventually. This PR exposes `treeHash` inputs and outputs in a few ways for this purpose. Eventually, we should add something like `builtins.derivation`'s `outputHashMode` to `builtins.fetchTree`, in order to specify we should use git hashing, and then this and the store-layer git hashing should meet together, ensuring we have the same tree hash end-to-end. Part of RFC 133 Co-Authored-By: Matthew Bauer <[email protected]> Co-Authored-By: Carlo Nucera <[email protected]> Co-authored-by: Robert Hensing <[email protected]>
- Loading branch information
1 parent
ce9ea7e
commit a8314ff
Showing
6 changed files
with
155 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
source common.sh | ||
|
||
[[ -n $(type -p git) ]] || skipTest "no git" | ||
|
||
repo=$TEST_ROOT/git | ||
|
||
rm -rf $repo $TEST_HOME/.cache/nix | ||
|
||
git init $repo | ||
git -C $repo config user.email "[email protected]" | ||
git -C $repo config user.name "Foobar" | ||
|
||
echo utrecht > $repo/hello | ||
touch $repo/.gitignore | ||
git -C $repo add hello .gitignore | ||
git -C $repo commit -m 'Bla1' | ||
|
||
echo world > $repo/hello | ||
git -C $repo commit -m 'Bla2' -a | ||
|
||
treeHash=$(git -C $repo rev-parse HEAD:) | ||
|
||
# Fetch the default branch. | ||
path=$(nix eval --raw --expr "(builtins.fetchTree { type = \"git\"; url = file://$repo; treeHash = \"$treeHash\"; }).outPath") | ||
[[ $(cat $path/hello) = world ]] | ||
|
||
# Submodules are fine with nar hashing the result | ||
pathSub=$(nix eval --raw --expr "(builtins.fetchTree { type = \"git\"; url = file://$repo; treeHash = \"$treeHash\"; submodules = true; }).outPath") | ||
[[ "$path" = "$pathSub" ]] | ||
|
||
# This might not work any more because of caching changes? | ||
# | ||
# # Check that we can substitute it from other places. | ||
# nix copy --to file://$cacheDir $path | ||
# nix-store --delete $path | ||
# path2=$(nix eval --raw --expr "(builtins.fetchTree { type = \"git\"; url = file:///no-such-repo; treeHash = \"$treeHash\"; }).outPath" --substituters file://$cacheDir --option substitute true) | ||
# [ $path2 = $path ] | ||
|
||
# HEAD should be the same path and tree hash as tree | ||
nix eval --impure --expr "(builtins.fetchTree { type = \"git\"; url = file://$repo; ref = \"HEAD\"; })" | ||
treeHash2=$(nix eval --impure --raw --expr "(builtins.fetchTree { type = \"git\"; url = file://$repo; ref = \"HEAD\"; }).treeHash") | ||
[ $treeHash = $treeHash2 ] | ||
path3=$(nix eval --impure --raw --expr "(builtins.fetchTree { type = \"git\"; url = file://$repo; ref = \"HEAD\"; }).outPath") | ||
[ $path3 = $path ] | ||
caFromNix=$(nix path-info --json "$path" | jq -r ".[] | .ca") | ||
|
||
# FIXME still using NAR hashing, should use git hashing | ||
# test "fixed:git:sha1:$(nix hash convert --to nix32 "sha1:$treeHash")" = "$caFromNix" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
git-hashing-tests := \ | ||
$(d)/simple.sh | ||
$(d)/simple.sh \ | ||
$(d)/fetching.sh | ||
|
||
install-tests-groups += git-hashing | ||
|
||
|