Updates to error handling for unset configs. (#1444)

Co-authored-by: Lawrence Cook <lawrencescook@gmail.com>
This commit is contained in:
Vinai Rachakonda
2021-03-16 15:03:14 -04:00
committed by GitHub
parent ebf57383e9
commit 0c1d7553ac
2 changed files with 25 additions and 2 deletions

View File

@@ -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 == "" {

View File

@@ -164,3 +164,26 @@ teardown() {
regex='John Doe <john@doe.com>'
[[ "$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
}