| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 |
|
| 19 | |
| 20 | output="t-download-$$"
|
| 21 | test_git_repo="$(mktemp -d)"
|
| 22 | output_dir="t-archive-dir-$$"
|
| 23 | trap 'rm -rf "$test_git_repo" ; rm -f "$output" ; rm -rf "$output_dir"' EXIT
|
| 24 |
|
| 25 | |
| 26 | |
| 27 | |
| 28 |
|
| 29 | guix download --version
|
| 30 |
|
| 31 | |
| 32 | guix download http://does.not/exist && false
|
| 33 |
|
| 34 | guix download unknown://some/where && false
|
| 35 |
|
| 36 | guix download /does-not-exist && false
|
| 37 |
|
| 38 | |
| 39 | guix download "file://$abs_top_srcdir/README"
|
| 40 |
|
| 41 | |
| 42 | guix download "$abs_top_srcdir/README"
|
| 43 |
|
| 44 | |
| 45 | GUIX_DAEMON_SOCKET="/nowhere" guix download -o "$output" \
|
| 46 | "file://$abs_top_srcdir/README"
|
| 47 | cmp "$output" "$abs_top_srcdir/README"
|
| 48 |
|
| 49 | |
| 50 | guix download "file:///does-not-exist" "file://$abs_top_srcdir/README" && false
|
| 51 |
|
| 52 | |
| 53 | |
| 54 | (
|
| 55 | |
| 56 | GIT_CONFIG_GLOBAL=/dev/null
|
| 57 | GIT_CONFIG_SYSTEM=/dev/null
|
| 58 | export GIT_CONFIG_SYSTEM GIT_CONFIG_GLOBAL
|
| 59 |
|
| 60 | cd $test_git_repo
|
| 61 | git init
|
| 62 | touch test
|
| 63 | git config user.name "User"
|
| 64 | git config user.email "user@domain"
|
| 65 | git add test
|
| 66 | git commit -m "Commit"
|
| 67 | git tag -a -m "v1" v1
|
| 68 | )
|
| 69 |
|
| 70 | |
| 71 | commit=$((cd $test_git_repo && git log) | head -n 1 | cut -f2 -d' ')
|
| 72 |
|
| 73 | |
| 74 | |
| 75 | expected_hash=$(guix hash -rx $test_git_repo)
|
| 76 |
|
| 77 | |
| 78 | for option in "" "--commit=$commit" "--commit=v1" "--branch=master"
|
| 79 | do
|
| 80 | command_output="$(guix download --git $option "file://$test_git_repo")"
|
| 81 | computed_hash="$(echo $command_output | cut -f2 -d' ')"
|
| 82 | store_path="$(echo $command_output | cut -f1 -d' ')"
|
| 83 | [ "$expected_hash" = "$computed_hash" ]
|
| 84 | diff -r -x ".git" $test_git_repo $store_path
|
| 85 | done
|
| 86 |
|
| 87 | |
| 88 | guix download --git --branch=non_existent "file://$test_git_repo" && false
|
| 89 |
|
| 90 | |
| 91 | guix download --git "file://$test_git_repo" -o $output_dir
|
| 92 | diff -r -x ".git" $test_git_repo $output_dir
|
| 93 |
|
| 94 | exit 0
|