From 0c1d7553ac0cd87f9dd14346f142cd24fbb7cd41 Mon Sep 17 00:00:00 2001 From: Vinai Rachakonda Date: Tue, 16 Mar 2021 15:03:14 -0400 Subject: [PATCH] Updates to error handling for unset configs. (#1444) Co-authored-by: Lawrence Cook --- go/libraries/doltcore/doltdb/commit_meta.go | 4 ++-- integration-tests/bats/config.bats | 23 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/go/libraries/doltcore/doltdb/commit_meta.go b/go/libraries/doltcore/doltdb/commit_meta.go index ecfc3d7a70..457c8eaf9e 100644 --- a/go/libraries/doltcore/doltdb/commit_meta.go +++ b/go/libraries/doltcore/doltdb/commit_meta.go @@ -64,11 +64,11 @@ func NewCommitMetaWithUserTS(name, email, desc string, userTS time.Time) (*Commi d := strings.TrimSpace(desc) if n == "" { - return nil, errors.New("Aborting commit due to empty committer name.") + return nil, errors.New("Aborting commit due to empty committer name. Is your config set?") } if e == "" { - return nil, errors.New("Aborting commit due to empty committer email.") + return nil, errors.New("Aborting commit due to empty committer email. Is your config set?") } if d == "" { diff --git a/integration-tests/bats/config.bats b/integration-tests/bats/config.bats index 5d186633b1..1dbafee8d3 100644 --- a/integration-tests/bats/config.bats +++ b/integration-tests/bats/config.bats @@ -164,3 +164,26 @@ teardown() { regex='John Doe ' [[ "$output" =~ "$regex" ]] || false } + +@test "config: COMMIT correctly errors when user.name or user.email is unset." { + dolt config --global --add user.name "bats tester" + dolt config --global --add user.email "joshn@doe.com" + + dolt init + dolt sql -q " + CREATE TABLE test ( + pk int primary key + )" + + dolt config --global --unset user.name + dolt config --global --unset user.email + + run dolt sql -q "SET @@dolt_repo_$$_head = COMMIT('-a', '-m', 'updated stuff')" + [ "$status" -eq 1 ] + [[ "$output" =~ "Aborting commit due to empty committer name. Is your config set" ]] || false + + dolt config --global --add user.name "bats tester" + run dolt sql -q "SET @@dolt_repo_$$_head = COMMIT('-a', '-m', 'updated stuff')" + [ "$status" -eq 1 ] + [[ "$output" =~ "Aborting commit due to empty committer email. Is your config set" ]] || false +} \ No newline at end of file