Skip to content

Commit

Permalink
Handle WORKING and STAGED as --no-pretty options
Browse files Browse the repository at this point in the history
  • Loading branch information
macneale4 committed Jan 10, 2025
1 parent d4b2722 commit c6cd6b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 5 additions & 2 deletions go/cmd/dolt/commands/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions integration-tests/bats/show.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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" {
Expand Down

0 comments on commit c6cd6b4

Please sign in to comment.