mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
fetchTree/fetchGit: re-enable shallow fetching
Add several tests for git fetching: - shallow-cache-separation: can fetch the same repo shallowly and non-shallowly - shallow-ignore-ref: ensure that ref gets ignored when shallow=true is set - ssh-shallow: can fetch a git repo via ssh using shallow=1
This commit is contained in:
parent
d762caff46
commit
bc00fa4647
6 changed files with 168 additions and 8 deletions
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
description = "ensure that ref gets ignored when shallow=true is set";
|
||||
script = ''
|
||||
# create branch1 off of main
|
||||
client.succeed(f"""
|
||||
echo chiang-mai > {repo.path}/thailand \
|
||||
&& {repo.git} add thailand \
|
||||
&& {repo.git} commit -m 'commit1' \
|
||||
\
|
||||
&& {repo.git} checkout -b branch1 main \
|
||||
&& echo bangkok > {repo.path}/thailand \
|
||||
&& {repo.git} add thailand \
|
||||
&& {repo.git} commit -m 'commit2' \
|
||||
\
|
||||
&& {repo.git} push origin --all
|
||||
""")
|
||||
|
||||
# save the revisions
|
||||
mainRev = client.succeed(f"""
|
||||
{repo.git} rev-parse main
|
||||
""").strip()
|
||||
branch1Rev = client.succeed(f"""
|
||||
{repo.git} rev-parse branch1
|
||||
""").strip()
|
||||
|
||||
# Ensure that ref gets ignored when fetching shallowly.
|
||||
# This would fail if the ref was respected, as branch1Rev is not on main.
|
||||
client.succeed(f"""
|
||||
nix eval --impure --raw --expr '
|
||||
(builtins.fetchGit {{
|
||||
url = "{repo.remote}";
|
||||
rev = "{branch1Rev}";
|
||||
ref = "main";
|
||||
shallow = true;
|
||||
}})
|
||||
'
|
||||
""")
|
||||
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue