2024-01-18 21:56:33 +02:00
|
|
|
{ config, ... }:
|
2024-01-11 09:41:35 +02:00
|
|
|
{
|
|
|
|
description = "can fetch a git repo via http";
|
|
|
|
script = ''
|
|
|
|
# add a file to the repo
|
|
|
|
client.succeed(f"""
|
2024-01-18 21:56:33 +02:00
|
|
|
echo ${config.name /* to make the git tree and store path unique */} > {repo.path}/test-case \
|
|
|
|
&& echo chiang-mai > {repo.path}/thailand \
|
|
|
|
&& {repo.git} add test-case thailand \
|
2024-01-11 09:41:35 +02:00
|
|
|
&& {repo.git} commit -m 'commit1'
|
|
|
|
""")
|
|
|
|
|
2024-01-18 14:42:41 +02:00
|
|
|
# save the revision
|
2024-01-11 09:41:35 +02:00
|
|
|
rev1 = client.succeed(f"""
|
|
|
|
{repo.git} rev-parse HEAD
|
|
|
|
""").strip()
|
|
|
|
|
|
|
|
# push to the server
|
|
|
|
client.succeed(f"""
|
|
|
|
{repo.git} push origin main
|
|
|
|
""")
|
|
|
|
|
|
|
|
# fetch the repo via nix
|
|
|
|
fetched1 = client.succeed(f"""
|
|
|
|
nix eval --impure --raw --expr "(builtins.fetchGit {repo.remote}).outPath"
|
|
|
|
""")
|
|
|
|
|
|
|
|
# check if the committed file is there
|
|
|
|
client.succeed(f"""
|
|
|
|
test -f {fetched1}/thailand
|
|
|
|
""")
|
|
|
|
|
|
|
|
# check if the revision is the same
|
|
|
|
rev1_fetched = client.succeed(f"""
|
|
|
|
nix eval --impure --raw --expr "(builtins.fetchGit {repo.remote}).rev"
|
|
|
|
""").strip()
|
|
|
|
assert rev1 == rev1_fetched, f"rev1: {rev1} != rev1_fetched: {rev1_fetched}"
|
|
|
|
'';
|
|
|
|
}
|