/{docker,go,integration-tests}: install git, remote .git suffix on clone in server

This commit is contained in:
coffeegoddd☕️✨
2026-02-12 13:37:13 -08:00
parent 661248a600
commit 7fe6eb7517
4 changed files with 66 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ ARG DOLT_VERSION
RUN apt update -y && \
apt install -y \
curl \
git \
tini \
ca-certificates && \
apt clean && \

View File

@@ -4,7 +4,7 @@ FROM debian:bookworm-slim AS base
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
curl tini ca-certificates && \
curl git tini ca-certificates && \
rm -rf /var/lib/apt/lists/*

View File

@@ -113,6 +113,13 @@ func getDirectoryAndUrlString(apr *argparser.ArgParseResults) (string, string, e
} else if dir == "/" {
return "", "", errhand.BuildDError("Could not infer repo name. Please explicitly define a directory for this url").Build()
}
// Match `dolt clone` behavior: strip a trailing `.git` from inferred names.
if strings.HasSuffix(dir, ".git") {
dir = strings.TrimSuffix(dir, ".git")
if dir == "" {
return "", "", errhand.BuildDError("Could not infer repo name. Please explicitly define a directory for this url").Build()
}
}
}
return dir, urlStr, nil

View File

@@ -120,6 +120,63 @@ EOF
dolt --use-db 'test01' sql -q "call dolt_clone('file:///$tempDir/remote')"
}
@test "sql-server: dolt_clone strips .git suffix for git remotes" {
skiponwindows "tests are flaky on Windows"
skip_if_remote
if ! command -v git >/dev/null 2>&1; then
skip "git not installed"
fi
tempDir=$(mktemp -d)
cd $tempDir
# Set up a bare git remote whose path ends with .git and seed it with a branch.
mkdir first_dolt_remote.git
git init --bare first_dolt_remote.git
seed_dir="$(mktemp -d "${BATS_TMPDIR:-/tmp}/seed-repo.XXXXXX")"
(
set -euo pipefail
trap 'rm -rf "$seed_dir"' EXIT
cd "$seed_dir"
git init >/dev/null
git config user.email "bats@email.fake"
git config user.name "Bats Tests"
echo "seed" > README
git add README
git commit -m "seed" >/dev/null
git branch -M main
git remote add origin "$tempDir/first_dolt_remote.git"
git push origin main >/dev/null
)
# Push dolt data to the git remote.
mkdir src
cd src
dolt init
dolt sql -q "create table test(pk int primary key, v int);"
dolt sql -q "insert into test values (1, 111);"
dolt add .
dolt commit -m "seed dolt"
dolt remote add origin "$tempDir/first_dolt_remote.git"
dolt push origin main
# Start an empty server and clone into it via the stored procedure.
cd "$tempDir"
mkdir empty_server
cd empty_server
start_sql_server
dolt sql -q "create database hostdb"
run dolt --use-db hostdb sql -q "call dolt_clone('$tempDir/first_dolt_remote.git'); show databases;"
[ "$status" -eq 0 ]
[[ "$output" =~ "first_dolt_remote" ]] || false
[[ ! "$output" =~ "first_dolt_remote.git" ]] || false
run dolt --use-db first_dolt_remote sql -q "select v from test where pk=1;" -r csv
[ "$status" -eq 0 ]
[[ "$output" =~ "111" ]] || false
}
@test "sql-server: loglevels are case insensitive" {
# assert that loglevel on command line is not case sensitive
cd repo1