mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 06:56:14 +02:00
bc00fa4647
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
57 lines
1.6 KiB
Nix
57 lines
1.6 KiB
Nix
{
|
|
description = "can fetch the same repo shallowly and non-shallowly";
|
|
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} push origin --all
|
|
""")
|
|
|
|
# save the revision
|
|
mainRev = client.succeed(f"""
|
|
{repo.git} rev-parse main
|
|
""").strip()
|
|
|
|
# fetch shallowly
|
|
revCountShallow = client.succeed(f"""
|
|
nix eval --impure --expr '
|
|
(builtins.fetchGit {{
|
|
url = "{repo.remote}";
|
|
rev = "{mainRev}";
|
|
shallow = true;
|
|
}}).revCount
|
|
'
|
|
""").strip()
|
|
# ensure the revCount is 0
|
|
assert revCountShallow == "0", f"revCountShallow should be 0, but is {revCountShallow}"
|
|
|
|
# fetch non-shallowly
|
|
revCountNonShallow = client.succeed(f"""
|
|
nix eval --impure --expr '
|
|
(builtins.fetchGit {{
|
|
url = "{repo.remote}";
|
|
rev = "{mainRev}";
|
|
shallow = false;
|
|
}}).revCount
|
|
'
|
|
""").strip()
|
|
# ensure the revCount is 1
|
|
assert revCountNonShallow == "1", f"revCountNonShallow should be 1, but is {revCountNonShallow}"
|
|
|
|
# fetch shallowly again
|
|
revCountShallow2 = client.succeed(f"""
|
|
nix eval --impure --expr '
|
|
(builtins.fetchGit {{
|
|
url = "{repo.remote}";
|
|
rev = "{mainRev}";
|
|
shallow = true;
|
|
}}).revCount
|
|
'
|
|
""").strip()
|
|
# ensure the revCount is 0
|
|
assert revCountShallow2 == "0", f"revCountShallow2 should be 0, but is {revCountShallow2}"
|
|
'';
|
|
}
|