From c6cd6b441b9a0b361f1bf3c5a5ce36ef0b662317 Mon Sep 17 00:00:00 2001 From: Neil Macneale IV Date: Fri, 10 Jan 2025 14:13:08 -0800 Subject: [PATCH] Handle WORKING and STAGED as --no-pretty options --- go/cmd/dolt/commands/show.go | 7 +++++-- integration-tests/bats/show.bats | 9 ++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/go/cmd/dolt/commands/show.go b/go/cmd/dolt/commands/show.go index 9058c392e52..fc4a90bdac4 100644 --- a/go/cmd/dolt/commands/show.go +++ b/go/cmd/dolt/commands/show.go @@ -129,12 +129,15 @@ func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, d resolvedRefs := make([]string, 0, len(opts.specRefs)) for _, specRef := range opts.specRefs { - if !hashRegex.MatchString(specRef) && !strings.EqualFold(specRef, "HEAD") { + if !hashRegex.MatchString(specRef) && + !strings.EqualFold(specRef, "HEAD") && + !strings.EqualFold(specRef, "WORKING") && + !strings.EqualFold(specRef, "STAGED") { // Call "dolt_hashof" to resolve the ref to a hash. the --no-pretty flag gets around the commit requirement, but // requires the full object name so it will match the hashRegex and never hit this code block. h, err2 := getHashOf(queryist, sqlCtx, specRef) if err2 != nil { - cli.PrintErrln("error: failed to resolve ref to commit: %s ", specRef) + cli.PrintErrln(fmt.Sprintf("branch not found: %s", specRef)) return 1 } resolvedRefs = append(resolvedRefs, h) diff --git a/integration-tests/bats/show.bats b/integration-tests/bats/show.bats index c1c57cac22f..5f762e17eda 100644 --- a/integration-tests/bats/show.bats +++ b/integration-tests/bats/show.bats @@ -191,7 +191,7 @@ assert_has_key_value() { dolt add . dolt sql -q "create table table3 (pk int PRIMARY KEY)" dolt sql -q "insert into table1 values (7), (8), (9)" - run dolt show WORKING + run dolt show --no-pretty WORKING [ $status -eq 0 ] [[ "$output" =~ "table1" ]] || false [[ "$output" =~ "table2" ]] || false @@ -208,7 +208,7 @@ assert_has_key_value() { dolt add . dolt sql -q "create table table3 (pk int PRIMARY KEY)" dolt sql -q "insert into table1 values (7), (8), (9)" - run dolt show STAGED + run dolt show --no-pretty STAGED [ $status -eq 0 ] [[ "$output" =~ "table1" ]] || false [[ "$output" =~ "table2" ]] || false @@ -225,16 +225,15 @@ assert_has_key_value() { dolt add . dolt sql -q "create table table3 (pk int PRIMARY KEY)" dolt sql -q "insert into table1 values (7), (8), (9)" - workingRoot=$(dolt show WORKING) + workingRoot=$(dolt show --no-pretty WORKING) tableAddress=$(extract_value table1 "$workingRoot") - run dolt show $tableAddress + run dolt show --no-pretty $tableAddress assert_has_key Schema "$output" assert_has_key Violations "$output" assert_has_key Autoinc "$output" assert_has_key "Primary index" "$output" assert_has_key "Secondary indexes" "$output" - } @test "show: pretty commit from hash" {