From 65719c72466daabe6a004dcafe3e4724d975bdcb Mon Sep 17 00:00:00 2001 From: Stephanie You Date: Thu, 15 Jun 2023 17:41:07 -0700 Subject: [PATCH] updates dolt commit to properly display skip empty commit message --- go/cmd/dolt/commands/commit.go | 11 +++++++++-- integration-tests/bats/commit.bats | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/go/cmd/dolt/commands/commit.go b/go/cmd/dolt/commands/commit.go index 64b9fd2337..fa3e25b8d0 100644 --- a/go/cmd/dolt/commands/commit.go +++ b/go/cmd/dolt/commands/commit.go @@ -158,14 +158,21 @@ func performCommit(ctx context.Context, commandStr string, args []string, cliCtx return 1, false } - _, _, err = queryist.Query(sqlCtx, q) + schema, rowIter, err := queryist.Query(sqlCtx, q) if err != nil { cli.Println(err.Error()) return 1, false } + resultRow, err := sql.RowIterToRows(sqlCtx, schema, rowIter) + if err != nil { + return 0, false + } + if resultRow == nil { + return 0, true + } // TODO: when dolt log is migrated, remove this block printing out the commit and print with a dolt log call in Exec() - schema, rowIter, err := queryist.Query(sqlCtx, "select * from dolt_log() limit 1") + schema, rowIter, err = queryist.Query(sqlCtx, "select * from dolt_log() limit 1") if err != nil { cli.Println(err.Error()) return 1, false diff --git a/integration-tests/bats/commit.bats b/integration-tests/bats/commit.bats index a89c39f387..221991287e 100644 --- a/integration-tests/bats/commit.bats +++ b/integration-tests/bats/commit.bats @@ -110,8 +110,9 @@ teardown() { [ $original_head != $new_head ] # When no changes are staged, --skip-empty skips creating the commit - dolt commit --skip-empty -m "commit message" + run dolt commit --skip-empty -m "commit message" [ $new_head = $(get_head_commit) ] + [[ "$output" =~ "Skipping empty commit" ]] || false } @test "commit: -f works correctly" {