Skip to content

Commit 4c1fbc8

Browse files
committed
amend bats and workbench mysql-client integrations
1 parent c6e1eb3 commit 4c1fbc8

15 files changed

Lines changed: 110 additions & 57 deletions

File tree

go/cmd/dolt/commands/commit.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -239,20 +239,15 @@ func constructParametrizedDoltCommitQuery(msg string, apr *argparser.ArgParseRes
239239
writeToBuffer("-f")
240240
}
241241

242-
writeToBuffer("--author")
243-
param = true
244-
writeToBuffer("?")
245-
var author string
246242
if apr.Contains(cli.AuthorParam) {
247-
author, _ = apr.GetValue(cli.AuthorParam)
248-
} else {
249-
name, email, err := env.GetNameAndEmail(cliCtx.Config())
250-
if err != nil {
251-
return "", nil, err
252-
}
253-
author = name + " <" + email + ">"
243+
writeToBuffer("--author")
244+
param = true
245+
writeToBuffer("?")
246+
author, _ := apr.GetValue(cli.AuthorParam)
247+
params = append(params, author)
248+
} else if _, _, err := env.GetNameAndEmail(cliCtx.Config()); err != nil {
249+
return "", nil, err
254250
}
255-
params = append(params, author)
256251

257252
if apr.Contains(cli.AllFlag) {
258253
writeToBuffer("-a")

go/libraries/doltcore/sqle/enginetest/dolt_queries.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,7 +2684,8 @@ WHERE z IN (
26842684
},
26852685
},
26862686
{
2687-
Name: "dolt_history_dolt_schemas committer column when unset reflects --author",
2687+
Name: "dolt_history_dolt_schemas committer column when unset reflects --author",
2688+
Dialect: "mysql",
26882689
SetUpScript: []string{
26892690
"CREATE VIEW v1 AS SELECT 1",
26902691
"CALL DOLT_COMMIT('-Am', 'create view', '--author', 'Test Author <test@example.com>')",
@@ -2697,7 +2698,8 @@ WHERE z IN (
26972698
},
26982699
},
26992700
{
2700-
Name: "dolt_history_dolt_procedures committer column when unset reflects --author",
2701+
Name: "dolt_history_dolt_procedures committer column when unset reflects --author",
2702+
Dialect: "mysql",
27012703
SetUpScript: []string{
27022704
"CREATE PROCEDURE p1() SELECT 1",
27032705
"CALL DOLT_COMMIT('-Am', 'create procedure', '--author', 'Test Author <test@example.com>')",

go/libraries/doltcore/sqle/system_variables.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,55 @@ var DoltSystemVariables = []sql.SystemVariable{
300300
Type: types.NewSystemStringType(actions.DoltCommitVerificationGroups),
301301
Default: "",
302302
},
303+
&sql.MysqlSystemVariable{
304+
Name: dsess.DoltLogCommitterOnly,
305+
Dynamic: true,
306+
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Both),
307+
Type: types.NewSystemBoolType(dsess.DoltLogCommitterOnly),
308+
Default: int8(0),
309+
},
310+
&sql.MysqlSystemVariable{
311+
Name: dsess.DoltAuthorName,
312+
Dynamic: true,
313+
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Session),
314+
Type: types.NewSystemStringType(dsess.DoltAuthorName),
315+
Default: "",
316+
},
317+
&sql.MysqlSystemVariable{
318+
Name: dsess.DoltAuthorEmail,
319+
Dynamic: true,
320+
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Session),
321+
Type: types.NewSystemStringType(dsess.DoltAuthorEmail),
322+
Default: "",
323+
},
324+
&sql.MysqlSystemVariable{
325+
Name: dsess.DoltAuthorDate,
326+
Dynamic: true,
327+
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Session),
328+
Type: types.NewSystemStringType(dsess.DoltAuthorDate),
329+
Default: "",
330+
},
331+
&sql.MysqlSystemVariable{
332+
Name: dsess.DoltCommitterName,
333+
Dynamic: true,
334+
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Session),
335+
Type: types.NewSystemStringType(dsess.DoltCommitterName),
336+
Default: "",
337+
},
338+
&sql.MysqlSystemVariable{
339+
Name: dsess.DoltCommitterEmail,
340+
Dynamic: true,
341+
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Session),
342+
Type: types.NewSystemStringType(dsess.DoltCommitterEmail),
343+
Default: "",
344+
},
345+
&sql.MysqlSystemVariable{
346+
Name: dsess.DoltCommitterDate,
347+
Dynamic: true,
348+
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Session),
349+
Type: types.NewSystemStringType(dsess.DoltCommitterDate),
350+
Default: "",
351+
},
303352
}
304353

305354
func AddDoltSystemVariables() {

integration-tests/bats/cherry-pick.bats

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -586,18 +586,18 @@ teardown() {
586586
[ $status -eq 0 ]
587587
[[ "$output" =~ "Original Author <original@example.com>" ]] || false
588588

589-
run dolt cherry-pick $COMMIT_HASH
589+
run env TZ=PST+8 DOLT_COMMITTER_DATE='2023-09-26T01:23:45' dolt cherry-pick $COMMIT_HASH
590590
[ $status -eq 0 ]
591591

592592
run dolt log -n 1
593593
[ $status -eq 0 ]
594594
[[ "$output" =~ "Original Author <original@example.com>" ]] || false
595595

596596
# Extended schema needed to verify author fields separately from committer
597-
run dolt sql -q "SELECT author, author_email, author_date FROM dolt_log WHERE message = 'commit with specific author'" -r csv
597+
run dolt sql -r csv -q "SELECT committer, email, date, author, author_email, author_date FROM dolt_log WHERE message = 'commit with specific author'"
598598
[ $status -eq 0 ]
599-
[[ "$output" =~ "Original Author,original@example.com" ]] || false
600-
[[ "$output" =~ "2023-09-26 01:23:45" ]] || false
599+
[[ "${lines[0]}" == "committer,email,date,author,author_email,author_date" ]] || false
600+
[[ "${lines[1]}" == "Bats Tests,bats@email.fake,2023-09-26 01:23:45.000,Original Author,original@example.com,2023-09-26 01:23:45" ]] || false
601601
}
602602

603603
@test "cherry-pick: multiple authors preserved in sequence with merge workflow" {
@@ -649,13 +649,14 @@ teardown() {
649649
[[ "$output" =~ "Carol Architect <carol@company.com>" ]] || false
650650
[[ "$output" =~ "Integration Manager <integration@company.com>" ]] || false
651651

652-
run dolt sql -q "SELECT author, author_email, message FROM dolt_log WHERE author IN ('Alice Developer', 'Bob Engineer', 'Carol Architect', 'Integration Manager') OR message LIKE 'Merge%' ORDER BY commit_order" -r csv
653-
[ $status -eq 0 ]
654-
[[ "$output" =~ "Alice Developer,alice@company.com" ]] || false
655-
[[ "$output" =~ "Bob Engineer,bob@company.com" ]] || false
656-
[[ "$output" =~ "Carol Architect,carol@company.com" ]] || false
657-
[[ "$output" =~ "Integration Manager,integration@company.com" ]] || false
658-
[[ "$output" =~ "Merge integration_branch" ]] || false
652+
run dolt sql -r csv -q "SELECT committer, email, author, author_email, message FROM dolt_log WHERE author IN ('Alice Developer', 'Bob Engineer', 'Carol Architect', 'Integration Manager') OR message LIKE 'Merge%' ORDER BY commit_order"
653+
[ $status -eq 0 ]
654+
[[ "${lines[0]}" == "committer,email,author,author_email,message" ]] || false
655+
[[ "${lines[1]}" == "Bats Tests,bats@email.fake,Alice Developer,alice@company.com,Alice's feature" ]] || false
656+
[[ "${lines[2]}" == "Bats Tests,bats@email.fake,Bob Engineer,bob@company.com,Bob's improvement" ]] || false
657+
[[ "${lines[3]}" == "Bats Tests,bats@email.fake,Carol Architect,carol@company.com,Carol's refactor" ]] || false
658+
[[ "${lines[4]}" == "Integration Manager,integration@company.com,Integration Manager,integration@company.com,prepare for merge" ]] || false
659+
[[ "${lines[5]}" == "Bats Tests,bats@email.fake,Bats Tests,bats@email.fake,Merge integration_branch" ]] || false
659660
}
660661
@test "cherry-pick: --continue after resolving conflicts" {
661662
dolt branch continue_test

integration-tests/bats/commit.bats

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ SQL
211211
}
212212

213213
@test "commit: no config set" {
214-
# In remote-engine mode, client identity variables are not forwarded to the server.
215-
skip_if_remote
216214
dolt config --global --unset user.email
217215
dolt config --global --unset user.name
218216

integration-tests/bats/config.bats

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,12 @@ function no_stdout {
234234

235235
dolt add .
236236
run dolt commit --author="John Doe <john@doe.com>" -m="Commit1"
237-
[ "$status" -ne 0 ]
238-
[[ "$output" =~ "Could not determine user.name" ]] || false
239-
240-
dolt config --global --add user.name "bats tester"
241-
dolt config --global --add user.email "joshn@doe.com"
237+
[ "$status" -eq 0 ]
242238

243-
run dolt commit --author="John Doe <john@doe.com>" -m="Commit1"
239+
run dolt log
244240
[ "$status" -eq 0 ]
245-
[[ "$output" =~ "John Doe <john@doe.com>" ]] || false
241+
regex='John Doe <john@doe.com>'
242+
[[ "$output" =~ "$regex" ]] || false
246243
}
247244

248245
@test "config: SQL can create databases with no user and email set" {

integration-tests/bats/sql-commit.bats

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,16 @@ SQL
284284
[ $new_head = $(get_head_commit) ]
285285
}
286286

287-
@test "sql-commit: committer environment variables set committer meta" {
287+
@test "sql-commit: committer and author environment variables set commit meta" {
288288
dolt sql -q "create table test_committer (pk int, c1 int, primary key(pk))"
289289
dolt add test_committer
290290
dolt commit -m "Initial commit"
291291

292+
run dolt sql -r csv -q "SELECT author, author_email, committer, email FROM dolt_log WHERE message = 'Initial commit'"
293+
[ "$status" -eq 0 ]
294+
[[ "$output" =~ author,author_email,committer,email ]] || false
295+
[[ "$output" =~ "Bats Tests,bats@email.fake,Bats Tests,bats@email.fake" ]] || false
296+
292297
dolt sql -q "create table test_committer2 (pk int, c1 int, primary key(pk))"
293298
dolt add test_committer2
294299
DOLT_COMMITTER_NAME="Test Committer" DOLT_COMMITTER_EMAIL="committer@test.com" dolt commit -m "Commit with different author and committer"
@@ -312,10 +317,10 @@ SQL
312317
dolt add test_committer4
313318
TZ=PST+8 DOLT_COMMITTER_NAME="Date Committer" DOLT_COMMITTER_EMAIL="date@committer.com" DOLT_COMMITTER_DATE='2023-09-26T12:34:56' DOLT_AUTHOR_DATE='2023-09-26T01:23:45' DOLT_AUTHOR_NAME='Date Author' dolt commit -m "Commit with different committer timestamp"
314319

315-
run dolt sql -r csv -q "SELECT committer, email, date FROM dolt_commits WHERE message = 'Commit with different committer timestamp'"
320+
run dolt sql -r csv -q "SELECT author, author_email, committer, email, date FROM dolt_commits WHERE message = 'Commit with different committer timestamp'"
316321
[ "$status" -eq 0 ]
317322
[[ "$output" =~ committer,email,date ]] || false
318-
[[ "$output" =~ "Date Committer,date@committer.com,2023-09-26 12:34:56" ]] || false
323+
[[ "$output" =~ "Date Author,bats@email.fake,Date Committer,date@committer.com,2023-09-26 12:34:56" ]] || false
319324

320325
run dolt sql -r csv -q "SELECT author, author_date, committer, date FROM dolt_log WHERE message = 'Commit with different committer timestamp'"
321326
[ "$status" -eq 0 ]

integration-tests/bats/sql-server.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ EOF
7070
dolt -u user1 sql -q "call dolt_commit('--author', 'barbie <barbie@plastic.com>', '-Am', 'committing as barbie');"
7171
run dolt -u user1 sql -q "select author, author_email, message, committer, email from dolt_log limit 1;" -r csv
7272
[ "$status" -eq 0 ]
73-
[[ $output =~ "barbie,barbie@plastic.com,committing as barbie,Bats Tests,bats@email.fake" ]] || false
73+
[[ $output =~ "barbie,barbie@plastic.com,committing as barbie,barbie,barbie@plastic.com" ]] || false
7474
}
7575

7676
@test "sql-server: can create savepoint when no database is selected" {

integration-tests/bats/sql.bats

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,17 +878,14 @@ SQL
878878

879879
@test "sql: AS OF queries" {
880880
dolt add .
881-
# --date sets the author date and AS OF timestamp resolves against the
882-
# committer date, so DOLT_COMMITTER_DATE is exported as well to pin both
883-
# sides of the commit identity to the same point in time.
884-
DOLT_COMMITTER_DATE="2020-03-01T12:00:00Z" dolt commit -m "Initial main commit" --date "2020-03-01T12:00:00Z"
881+
dolt commit -m "Initial main commit" --date "2020-03-01T12:00:00Z"
885882

886883
main_commit=`dolt log | head -n1 | cut -d' ' -f2`
887884
dolt sql -q "update one_pk set c1 = c1 + 1"
888885
dolt sql -q "drop table two_pk"
889886
dolt checkout -b new_branch
890887
dolt add .
891-
DOLT_COMMITTER_DATE="2020-03-01T13:00:00Z" dolt commit -m "Updated a table, dropped a table" --date "2020-03-01T13:00:00Z"
888+
dolt commit -m "Updated a table, dropped a table" --date "2020-03-01T13:00:00Z"
892889
new_commit=`dolt log | head -n1 | cut -d' ' -f2`
893890

894891
run dolt sql -r csv -q "select pk,c1 from one_pk order by c1"

integration-tests/compatibility/test_files/bats/bidirectional/server_cli_compat.bats renamed to integration-tests/compatibility/test_files/bats/server_cli_compat.bats

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#!/usr/bin/env bats
22
#
3-
# Verifies the SQL server and CLI client work across Dolt versions. DOLT_OLD_BIN and
4-
# DOLT_NEW_BIN are slot labels assigned by runner.sh; the bidirectional phase swaps them
5-
# between sub-runs, so neither name claims age. Tests reach the binaries via old_dolt and
6-
# new_dolt; new_dolt_cli targets the running sql-server. REPO_DIR is the pre-populated
7-
# repo from setup_repo.sh.
3+
# Verifies the SQL server and CLI client work across Dolt versions. DOLT_OLD_BIN runs
4+
# the sql-server, DOLT_NEW_BIN runs the client; both default to dolt on PATH. Tests
5+
# reach the binaries via old_dolt and new_dolt; new_dolt_cli targets the running
6+
# sql-server. REPO_DIR is the pre-populated repo from setup_repo.sh.
7+
#
8+
# This file lives at the test_files/bats/ root rather than bidirectional/ because it
9+
# requires REPO_DIR to be populated by setup_repo.sh, while the bidirectional sub-phase
10+
# hands tests an empty REPO_DIR for self-init coverage.
811

912
setup_file() {
1013
export BATS_TEST_RETRIES=3
@@ -64,7 +67,7 @@ teardown() {
6467
[[ "$revert_output" =~ "commit " ]] || false
6568

6669
# The revert must remove the row inserted above.
67-
run new_dolt_cli sql -r csv -q "SELECT count(*) AS n FROM big WHERE i = 10000;"
70+
run new_dolt_cli sql -r csv -q "SELECT count(*) AS n FROM big WHERE pk = 10000;"
6871
[ "$status" -eq 0 ]
6972
[[ "${lines[0]}" == "n" ]] || false
7073
[[ "${lines[1]}" == "0" ]] || false

0 commit comments

Comments
 (0)