From 19190c2346b84916c64737d895b87b570c673b96 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 13 Jul 2022 13:17:10 +0200 Subject: [PATCH] tests/flakes.sh: Make sure flake7 is clean Cherry-picked from the lazy-trees branch, where we no longer write a lock file if any of the inputs is dirty. --- tests/flakes.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/flakes.sh b/tests/flakes.sh index 9087e1978..265e4a456 100644 --- a/tests/flakes.sh +++ b/tests/flakes.sh @@ -28,6 +28,15 @@ flakeFollowsC=$TEST_ROOT/follows/flakeA/flakeB/flakeC flakeFollowsD=$TEST_ROOT/follows/flakeA/flakeD flakeFollowsE=$TEST_ROOT/follows/flakeA/flakeE +initRepo() { + local repo="$1" + local extraArgs="$2" + + git -C $repo init $extraArgs + git -C $repo config user.email "foobar@example.com" + git -C $repo config user.name "Foobar" +} + for repo in $flake1Dir $flake2Dir $flake3Dir $flake7Dir $templatesDir $nonFlakeDir $flakeA $flakeB $flakeFollowsA; do rm -rf $repo $repo.tmp mkdir -p $repo @@ -38,9 +47,7 @@ for repo in $flake1Dir $flake2Dir $flake3Dir $flake7Dir $templatesDir $nonFlakeD extraArgs="--initial-branch=main" fi - git -C $repo init $extraArgs - git -C $repo config user.email "foobar@example.com" - git -C $repo config user.name "Foobar" + initRepo "$repo" "$extraArgs" done cat > $flake1Dir/flake.nix < $flake7Dir/a (cd $flake7Dir && nix flake init) # check idempotence # Test 'nix flake init' with conflicts -rm -rf $flake7Dir && mkdir $flake7Dir && git -C $flake7Dir init +rm -rf $flake7Dir && mkdir $flake7Dir && initRepo "$flake7Dir" echo b > $flake7Dir/a pushd $flake7Dir (! nix flake init) |& grep "refusing to overwrite existing file '$flake7Dir/a'" popd +git -C $flake7Dir commit -a -m 'Changed' # Test 'nix flake new'. rm -rf $flake6Dir