#!/usr/bin/env bash
# Format probing must retain ordinary Git transports without shallow support.
require_cmd git
require_cmd python3
mkdir -p seed served
git -C seed init -q -b main
printf '[dotfiles]\n' >seed/config.toml
git -C seed add config.toml
git -C seed -c user.name=Test -c user.email=test@example.invalid commit -qm initial
git clone -q --bare seed served/origin.git
git --git-dir=served/origin.git update-server-info
start_http_server --dir served
url="http://127.0.0.1:$HTTP_PORT/origin.git"
git init -q --bare probe.git
assert_fail "git --git-dir=probe.git fetch --depth=1 '$url' main" 'dumb http transport does not support shallow capabilities'
assert_succeed "MISE_CONFIG_DIR='$PWD/target' mise bootstrap --adopt '$url' --only dotfiles --dry-run"
assert_fail 'test -e target/config.toml'
assert_succeed "MISE_CONFIG_DIR='$PWD/target' mise bootstrap --adopt '$url' --only dotfiles --yes"
assert_directory_exists 'target/.git'
assert 'cat target/config.toml' '[dotfiles]'
