Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ARG DOLT_VERSION
RUN apt update -y && \
apt install -y \
curl \
git \
tini \
ca-certificates && \
apt clean && \
Expand Down
2 changes: 1 addition & 1 deletion docker/serverDockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*


Expand Down
7 changes: 7 additions & 0 deletions go/libraries/doltcore/sqle/dprocedures/dolt_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 57 additions & 0 deletions integration-tests/bats/sql-server.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
coffeegoddd marked this conversation as resolved.
Outdated

# 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
Expand Down
Loading