feat: remove CGO build-tag bifurcation for dolt commands
Delete 6 CGO/nocgo stub files and remove //go:build cgo tags from dolt.go and bootstrap.go. Beads now always operates in server mode (dolt sql-server subprocess). Embedded mode references removed from CLI help text and config commands. Part of epic: Remove embedded Dolt mode (server-only operation). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
53e9f8cce8
commit
c4010c1977
11 changed files with 38 additions and 346 deletions
|
|
@ -1,5 +1,3 @@
|
|||
//go:build cgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
//go:build !cgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/steveyegge/beads/internal/storage/dolt"
|
||||
)
|
||||
|
||||
func bootstrapEmbeddedDolt(_ context.Context, _ string, _ *dolt.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//go:build cgo
|
||||
|
||||
package main
|
||||
|
||||
// cgoAvailable reports whether this binary was built with CGO support.
|
||||
// CGO is required for the embedded Dolt database backend.
|
||||
func cgoAvailable() bool {
|
||||
return true
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//go:build !cgo
|
||||
|
||||
package main
|
||||
|
||||
// cgoAvailable reports whether this binary was built with CGO support.
|
||||
// CGO is required for the embedded Dolt database backend.
|
||||
func cgoAvailable() bool {
|
||||
return false
|
||||
}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
//go:build cgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
|
@ -26,9 +24,7 @@ var doltCmd = &cobra.Command{
|
|||
Short: "Configure Dolt database settings",
|
||||
Long: `Configure and manage Dolt database settings and server lifecycle.
|
||||
|
||||
Dolt can run in two modes:
|
||||
- embedded: In-process database (default, single-process only)
|
||||
- server: Connect to external dolt sql-server (multi-process, high-concurrency)
|
||||
Beads connects to a running dolt sql-server for all database operations.
|
||||
|
||||
Commands:
|
||||
bd dolt show Show current Dolt configuration with connection test
|
||||
|
|
@ -41,7 +37,6 @@ Commands:
|
|||
bd dolt pull Pull commits from Dolt remote
|
||||
|
||||
Configuration keys for 'bd dolt set':
|
||||
mode Connection mode: "embedded" or "server"
|
||||
database Database name (default: issue prefix or "beads")
|
||||
host Server host (default: 127.0.0.1)
|
||||
port Server port (default: 3307)
|
||||
|
|
@ -53,7 +48,6 @@ Flags for 'bd dolt set':
|
|||
Examples:
|
||||
bd dolt start Start server with configured settings
|
||||
bd dolt stop Stop the running server
|
||||
bd dolt set mode server
|
||||
bd dolt set database myproject
|
||||
bd dolt set host 192.168.1.100 --update-config
|
||||
bd dolt test`,
|
||||
|
|
@ -73,8 +67,7 @@ var doltSetCmd = &cobra.Command{
|
|||
Long: `Set a Dolt configuration value in metadata.json.
|
||||
|
||||
Keys:
|
||||
mode Connection mode: "embedded" or "server"
|
||||
database Database name for server mode
|
||||
database Database name (default: issue prefix or "beads")
|
||||
host Server host (default: 127.0.0.1)
|
||||
port Server port (default: 3307)
|
||||
user MySQL user (default: root)
|
||||
|
|
@ -82,7 +75,6 @@ Keys:
|
|||
Use --update-config to also write to config.yaml for team-wide defaults.
|
||||
|
||||
Examples:
|
||||
bd dolt set mode server
|
||||
bd dolt set database myproject
|
||||
bd dolt set host 192.168.1.100
|
||||
bd dolt set port 3307 --update-config`,
|
||||
|
|
@ -285,12 +277,11 @@ func showDoltConfig(testConnection bool) {
|
|||
"backend": backend,
|
||||
}
|
||||
if backend == configfile.BackendDolt {
|
||||
result["mode"] = cfg.GetDoltMode()
|
||||
result["database"] = cfg.GetDoltDatabase()
|
||||
result["host"] = cfg.GetDoltServerHost()
|
||||
result["port"] = cfg.GetDoltServerPort()
|
||||
result["user"] = cfg.GetDoltServerUser()
|
||||
if cfg.IsDoltServerMode() && testConnection {
|
||||
if testConnection {
|
||||
result["connection_ok"] = testServerConnection(cfg)
|
||||
}
|
||||
}
|
||||
|
|
@ -305,21 +296,17 @@ func showDoltConfig(testConnection bool) {
|
|||
|
||||
fmt.Println("Dolt Configuration")
|
||||
fmt.Println("==================")
|
||||
fmt.Printf(" Mode: %s\n", cfg.GetDoltMode())
|
||||
fmt.Printf(" Database: %s\n", cfg.GetDoltDatabase())
|
||||
fmt.Printf(" Host: %s\n", cfg.GetDoltServerHost())
|
||||
fmt.Printf(" Port: %d\n", cfg.GetDoltServerPort())
|
||||
fmt.Printf(" User: %s\n", cfg.GetDoltServerUser())
|
||||
|
||||
if cfg.IsDoltServerMode() {
|
||||
fmt.Printf(" Host: %s\n", cfg.GetDoltServerHost())
|
||||
fmt.Printf(" Port: %d\n", cfg.GetDoltServerPort())
|
||||
fmt.Printf(" User: %s\n", cfg.GetDoltServerUser())
|
||||
|
||||
if testConnection {
|
||||
fmt.Println()
|
||||
if testServerConnection(cfg) {
|
||||
fmt.Printf(" %s\n", ui.RenderPass("✓ Server connection OK"))
|
||||
} else {
|
||||
fmt.Printf(" %s\n", ui.RenderWarn("✗ Server not reachable"))
|
||||
}
|
||||
if testConnection {
|
||||
fmt.Println()
|
||||
if testServerConnection(cfg) {
|
||||
fmt.Printf(" %s\n", ui.RenderPass("✓ Server connection OK"))
|
||||
} else {
|
||||
fmt.Printf(" %s\n", ui.RenderWarn("✗ Server not reachable"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -355,13 +342,8 @@ func setDoltConfig(key, value string, updateConfig bool) {
|
|||
|
||||
switch key {
|
||||
case "mode":
|
||||
if value != configfile.DoltModeEmbedded && value != configfile.DoltModeServer {
|
||||
fmt.Fprintf(os.Stderr, "Error: mode must be '%s' or '%s'\n",
|
||||
configfile.DoltModeEmbedded, configfile.DoltModeServer)
|
||||
os.Exit(1)
|
||||
}
|
||||
cfg.DoltMode = value
|
||||
yamlKey = "dolt.mode"
|
||||
fmt.Fprintf(os.Stderr, "Error: mode is no longer configurable; beads always uses server mode\n")
|
||||
os.Exit(1)
|
||||
|
||||
case "database":
|
||||
if value == "" {
|
||||
|
|
@ -611,11 +593,6 @@ func startDoltServer() {
|
|||
|
||||
fmt.Printf(" %s\n", ui.RenderPass(fmt.Sprintf("✓ Server started (PID %d)", pid)))
|
||||
fmt.Println()
|
||||
if !cfg.IsDoltServerMode() {
|
||||
fmt.Println("To use server mode:")
|
||||
fmt.Println(" bd dolt set mode server")
|
||||
fmt.Println()
|
||||
}
|
||||
fmt.Println("To stop the server:")
|
||||
fmt.Println(" bd dolt stop")
|
||||
}
|
||||
|
|
@ -627,8 +604,6 @@ func stopDoltServer() {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
cfg, _ := configfile.Load(beadsDir)
|
||||
|
||||
dataDir := filepath.Join(beadsDir, "dolt")
|
||||
|
||||
pid := dolt.GetRunningServerPID(dataDir)
|
||||
|
|
@ -675,13 +650,9 @@ func stopDoltServer() {
|
|||
|
||||
fmt.Printf("%s\n", ui.RenderPass("✓ Server stopped"))
|
||||
|
||||
// Warn if still in server mode
|
||||
if cfg != nil && cfg.IsDoltServerMode() {
|
||||
fmt.Println()
|
||||
fmt.Println("Note: You are still in server mode. bd commands will fail")
|
||||
fmt.Println("until the server is restarted or you switch to embedded mode:")
|
||||
fmt.Println(" bd dolt set mode embedded")
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Println("Note: bd commands require a running server.")
|
||||
fmt.Println("Restart with: bd dolt start")
|
||||
}
|
||||
|
||||
// logDoltConfigChange appends an audit entry to .beads/dolt-config.log.
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
//go:build !cgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func noCGODoltError(cmd *cobra.Command, args []string) {
|
||||
if jsonOutput {
|
||||
outputJSON(map[string]interface{}{
|
||||
"error": "dolt_not_available",
|
||||
"message": "Dolt commands require CGO. This binary was built without CGO support.",
|
||||
})
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "Error: Dolt commands require CGO\n")
|
||||
fmt.Fprintf(os.Stderr, "This binary was built without CGO support.\n")
|
||||
fmt.Fprintf(os.Stderr, "To use Dolt, rebuild with: CGO_ENABLED=1 go build\n")
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var doltCmd = &cobra.Command{
|
||||
Use: "dolt",
|
||||
GroupID: "setup",
|
||||
Short: "Configure Dolt database settings",
|
||||
Long: `Dolt commands require CGO. This binary was built without CGO support.`,
|
||||
Run: noCGODoltError,
|
||||
}
|
||||
|
||||
var doltShowCmdNoCGO = &cobra.Command{
|
||||
Use: "show",
|
||||
Short: "Show current Dolt configuration with connection status",
|
||||
Run: noCGODoltError,
|
||||
}
|
||||
|
||||
var doltSetCmdNoCGO = &cobra.Command{
|
||||
Use: "set <key> <value>",
|
||||
Short: "Set a Dolt configuration value",
|
||||
Args: cobra.ExactArgs(2),
|
||||
Run: noCGODoltError,
|
||||
}
|
||||
|
||||
var doltTestCmdNoCGO = &cobra.Command{
|
||||
Use: "test",
|
||||
Short: "Test connection to Dolt server",
|
||||
Run: noCGODoltError,
|
||||
}
|
||||
|
||||
var doltStartCmdNoCGO = &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start a Dolt SQL server using configured settings",
|
||||
Run: noCGODoltError,
|
||||
}
|
||||
|
||||
var doltStopCmdNoCGO = &cobra.Command{
|
||||
Use: "stop",
|
||||
Short: "Stop the running Dolt SQL server",
|
||||
Run: noCGODoltError,
|
||||
}
|
||||
|
||||
func init() {
|
||||
doltSetCmdNoCGO.Flags().Bool("update-config", false, "Also write to config.yaml for team-wide defaults")
|
||||
doltCmd.AddCommand(doltShowCmdNoCGO)
|
||||
doltCmd.AddCommand(doltSetCmdNoCGO)
|
||||
doltCmd.AddCommand(doltTestCmdNoCGO)
|
||||
doltCmd.AddCommand(doltStartCmdNoCGO)
|
||||
doltCmd.AddCommand(doltStopCmdNoCGO)
|
||||
rootCmd.AddCommand(doltCmd)
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
//go:build cgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/steveyegge/beads/internal/storage/dolt"
|
||||
)
|
||||
|
||||
// DoltServerHandle wraps a dolt.Server for CGO builds
|
||||
type DoltServerHandle struct {
|
||||
server *dolt.Server
|
||||
}
|
||||
|
||||
// DoltDefaultSQLPort is the default SQL port for dolt server
|
||||
const DoltDefaultSQLPort = dolt.DefaultSQLPort
|
||||
|
||||
// DoltDefaultRemotesAPIPort is the default remotesapi port for dolt server
|
||||
const DoltDefaultRemotesAPIPort = dolt.DefaultRemotesAPIPort
|
||||
|
||||
// StartDoltServer starts a dolt sql-server for federation mode
|
||||
func StartDoltServer(ctx context.Context, dataDir, logFile string, sqlPort, remotePort int) (*DoltServerHandle, error) {
|
||||
server := dolt.NewServer(dolt.ServerConfig{
|
||||
DataDir: dataDir,
|
||||
SQLPort: sqlPort,
|
||||
RemotesAPIPort: remotePort,
|
||||
Host: "127.0.0.1",
|
||||
LogFile: logFile,
|
||||
})
|
||||
|
||||
if err := server.Start(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &DoltServerHandle{server: server}, nil
|
||||
}
|
||||
|
||||
// Stop stops the dolt server
|
||||
func (h *DoltServerHandle) Stop() error {
|
||||
if h.server != nil {
|
||||
return h.server.Stop()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SQLPort returns the SQL port the server is listening on
|
||||
func (h *DoltServerHandle) SQLPort() int {
|
||||
if h.server != nil {
|
||||
return h.server.SQLPort()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// RemotesAPIPort returns the remotesapi port the server is listening on
|
||||
func (h *DoltServerHandle) RemotesAPIPort() int {
|
||||
if h.server != nil {
|
||||
return h.server.RemotesAPIPort()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Host returns the host the server is listening on
|
||||
func (h *DoltServerHandle) Host() string {
|
||||
if h.server != nil {
|
||||
return h.server.Host()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// DoltServerAvailable returns true when CGO is available
|
||||
func DoltServerAvailable() bool {
|
||||
return true
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
//go:build !cgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// DoltServerHandle is a stub for non-CGO builds
|
||||
type DoltServerHandle struct{}
|
||||
|
||||
// DoltDefaultSQLPort is the default SQL port for dolt server
|
||||
const DoltDefaultSQLPort = 3306
|
||||
|
||||
// DoltDefaultRemotesAPIPort is the default remotesapi port for dolt server
|
||||
const DoltDefaultRemotesAPIPort = 50051
|
||||
|
||||
// ErrDoltRequiresCGO is returned when dolt features are requested without CGO
|
||||
var ErrDoltRequiresCGO = errors.New("dolt backend requires CGO; use pre-built binaries from GitHub releases or enable CGO")
|
||||
|
||||
// StartDoltServer returns an error in non-CGO builds
|
||||
func StartDoltServer(ctx context.Context, dataDir, logFile string, sqlPort, remotePort int) (*DoltServerHandle, error) {
|
||||
return nil, ErrDoltRequiresCGO
|
||||
}
|
||||
|
||||
// Stop is a no-op stub
|
||||
func (h *DoltServerHandle) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SQLPort returns 0 in non-CGO builds
|
||||
func (h *DoltServerHandle) SQLPort() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// RemotesAPIPort returns 0 in non-CGO builds
|
||||
func (h *DoltServerHandle) RemotesAPIPort() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// Host returns empty string in non-CGO builds
|
||||
func (h *DoltServerHandle) Host() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// DoltServerAvailable returns false when CGO is not available
|
||||
func DoltServerAvailable() bool {
|
||||
return false
|
||||
}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
//go:build cgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
|
@ -41,17 +39,16 @@ func TestDoltShowConfigNotInRepo(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestDoltShowConfigEmbeddedMode(t *testing.T) {
|
||||
func TestDoltShowConfigDefaultMode(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
beadsDir := filepath.Join(tmpDir, ".beads")
|
||||
if err := os.MkdirAll(beadsDir, 0755); err != nil {
|
||||
t.Fatalf("failed to create .beads dir: %v", err)
|
||||
}
|
||||
|
||||
// Create metadata.json with Dolt backend in embedded mode
|
||||
// Create metadata.json with Dolt backend
|
||||
cfg := configfile.DefaultConfig()
|
||||
cfg.Backend = configfile.BackendDolt
|
||||
cfg.DoltMode = configfile.DoltModeEmbedded
|
||||
cfg.DoltDatabase = "testdb"
|
||||
if err := cfg.Save(beadsDir); err != nil {
|
||||
t.Fatalf("failed to save config: %v", err)
|
||||
|
|
@ -78,12 +75,12 @@ func TestDoltShowConfigEmbeddedMode(t *testing.T) {
|
|||
t.Skip("output capture failed")
|
||||
}
|
||||
|
||||
if !containsAny(output, "embedded", "Mode") {
|
||||
t.Errorf("output should show embedded mode: %s", output)
|
||||
}
|
||||
if !containsAny(output, "testdb", "Database") {
|
||||
t.Errorf("output should show database name: %s", output)
|
||||
}
|
||||
if !containsAny(output, "Host", "Port", "User") {
|
||||
t.Errorf("output should show server connection info: %s", output)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("json output", func(t *testing.T) {
|
||||
|
|
@ -105,12 +102,13 @@ func TestDoltShowConfigEmbeddedMode(t *testing.T) {
|
|||
if result["backend"] != "dolt" {
|
||||
t.Errorf("expected backend 'dolt', got %v", result["backend"])
|
||||
}
|
||||
if result["mode"] != "embedded" {
|
||||
t.Errorf("expected mode 'embedded', got %v", result["mode"])
|
||||
}
|
||||
if result["database"] != "testdb" {
|
||||
t.Errorf("expected database 'testdb', got %v", result["database"])
|
||||
}
|
||||
// mode field should no longer be present
|
||||
if _, ok := result["mode"]; ok {
|
||||
t.Error("mode field should no longer be in JSON output")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -154,9 +152,6 @@ func TestDoltShowConfigServerMode(t *testing.T) {
|
|||
t.Skip("output capture failed")
|
||||
}
|
||||
|
||||
if !containsAny(output, "server", "Mode") {
|
||||
t.Errorf("output should show server mode: %s", output)
|
||||
}
|
||||
if !containsAny(output, "192.168.1.100", "Host") {
|
||||
t.Errorf("output should show host: %s", output)
|
||||
}
|
||||
|
|
@ -184,9 +179,6 @@ func TestDoltShowConfigServerMode(t *testing.T) {
|
|||
t.Skipf("output not pure JSON: %s", output)
|
||||
}
|
||||
|
||||
if result["mode"] != "server" {
|
||||
t.Errorf("expected mode 'server', got %v", result["mode"])
|
||||
}
|
||||
if result["host"] != "192.168.1.100" {
|
||||
t.Errorf("expected host '192.168.1.100', got %v", result["host"])
|
||||
}
|
||||
|
|
@ -210,7 +202,6 @@ func TestDoltSetConfigValidation(t *testing.T) {
|
|||
// Create metadata.json with Dolt backend
|
||||
cfg := configfile.DefaultConfig()
|
||||
cfg.Backend = configfile.BackendDolt
|
||||
cfg.DoltMode = configfile.DoltModeEmbedded
|
||||
if err := cfg.Save(beadsDir); err != nil {
|
||||
t.Fatalf("failed to save config: %v", err)
|
||||
}
|
||||
|
|
@ -227,35 +218,6 @@ func TestDoltSetConfigValidation(t *testing.T) {
|
|||
}
|
||||
defer func() { _ = os.Chdir(oldCwd) }()
|
||||
|
||||
t.Run("set mode to server", func(t *testing.T) {
|
||||
origJsonOutput := jsonOutput
|
||||
defer func() { jsonOutput = origJsonOutput }()
|
||||
jsonOutput = false
|
||||
|
||||
setDoltConfig("mode", "server", false)
|
||||
|
||||
// Verify the change persisted
|
||||
loadedCfg, err := configfile.Load(beadsDir)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to load config: %v", err)
|
||||
}
|
||||
if loadedCfg.DoltMode != configfile.DoltModeServer {
|
||||
t.Errorf("expected mode 'server', got %s", loadedCfg.DoltMode)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("set mode to embedded", func(t *testing.T) {
|
||||
setDoltConfig("mode", "embedded", false)
|
||||
|
||||
loadedCfg, err := configfile.Load(beadsDir)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to load config: %v", err)
|
||||
}
|
||||
if loadedCfg.DoltMode != configfile.DoltModeEmbedded {
|
||||
t.Errorf("expected mode 'embedded', got %s", loadedCfg.DoltMode)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("set database", func(t *testing.T) {
|
||||
setDoltConfig("database", "mydb", false)
|
||||
|
||||
|
|
@ -314,7 +276,6 @@ func TestDoltSetConfigJSONOutput(t *testing.T) {
|
|||
|
||||
cfg := configfile.DefaultConfig()
|
||||
cfg.Backend = configfile.BackendDolt
|
||||
cfg.DoltMode = configfile.DoltModeEmbedded
|
||||
if err := cfg.Save(beadsDir); err != nil {
|
||||
t.Fatalf("failed to save config: %v", err)
|
||||
}
|
||||
|
|
@ -333,7 +294,7 @@ func TestDoltSetConfigJSONOutput(t *testing.T) {
|
|||
defer func() { jsonOutput = origJsonOutput }()
|
||||
jsonOutput = true
|
||||
|
||||
output := captureDoltSetOutput(t, "mode", "server", false)
|
||||
output := captureDoltSetOutput(t, "database", "myproject", false)
|
||||
|
||||
if output == "" {
|
||||
t.Skip("output capture failed")
|
||||
|
|
@ -344,11 +305,11 @@ func TestDoltSetConfigJSONOutput(t *testing.T) {
|
|||
t.Skipf("output not pure JSON: %s", output)
|
||||
}
|
||||
|
||||
if result["key"] != "mode" {
|
||||
t.Errorf("expected key 'mode', got %v", result["key"])
|
||||
if result["key"] != "database" {
|
||||
t.Errorf("expected key 'database', got %v", result["key"])
|
||||
}
|
||||
if result["value"] != "server" {
|
||||
t.Errorf("expected value 'server', got %v", result["value"])
|
||||
if result["value"] != "myproject" {
|
||||
t.Errorf("expected value 'myproject', got %v", result["value"])
|
||||
}
|
||||
if result["location"] != "metadata.json" {
|
||||
t.Errorf("expected location 'metadata.json', got %v", result["location"])
|
||||
|
|
@ -389,7 +350,7 @@ func TestDoltSetConfigWithUpdateConfig(t *testing.T) {
|
|||
jsonOutput = true
|
||||
|
||||
// Set with --update-config
|
||||
output := captureDoltSetOutput(t, "mode", "server", true)
|
||||
output := captureDoltSetOutput(t, "database", "myproject", true)
|
||||
|
||||
if output == "" {
|
||||
t.Skip("output capture failed")
|
||||
|
|
@ -556,7 +517,6 @@ func TestDoltStopNoServerRunning(t *testing.T) {
|
|||
|
||||
cfg := configfile.DefaultConfig()
|
||||
cfg.Backend = configfile.BackendDolt
|
||||
cfg.DoltMode = configfile.DoltModeEmbedded
|
||||
if err := cfg.Save(beadsDir); err != nil {
|
||||
t.Fatalf("failed to save config: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,10 @@ var versionCmd = &cobra.Command{
|
|||
commit := resolveCommitHash()
|
||||
branch := resolveBranch()
|
||||
|
||||
cgo := cgoAvailable()
|
||||
|
||||
if jsonOutput {
|
||||
result := map[string]interface{}{
|
||||
"version": Version,
|
||||
"build": Build,
|
||||
"cgo": cgo,
|
||||
}
|
||||
if commit != "" {
|
||||
result["commit"] = commit
|
||||
|
|
@ -43,16 +40,12 @@ var versionCmd = &cobra.Command{
|
|||
}
|
||||
outputJSON(result)
|
||||
} else {
|
||||
var cgoSuffix string
|
||||
if !cgo {
|
||||
cgoSuffix = " [NO CGO - embedded Dolt unavailable]"
|
||||
}
|
||||
if commit != "" && branch != "" {
|
||||
fmt.Printf("bd version %s (%s: %s@%s)%s\n", Version, Build, branch, shortCommit(commit), cgoSuffix)
|
||||
fmt.Printf("bd version %s (%s: %s@%s)\n", Version, Build, branch, shortCommit(commit))
|
||||
} else if commit != "" {
|
||||
fmt.Printf("bd version %s (%s: %s)%s\n", Version, Build, shortCommit(commit), cgoSuffix)
|
||||
fmt.Printf("bd version %s (%s: %s)\n", Version, Build, shortCommit(commit))
|
||||
} else {
|
||||
fmt.Printf("bd version %s (%s)%s\n", Version, Build, cgoSuffix)
|
||||
fmt.Printf("bd version %s (%s)\n", Version, Build)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -73,11 +73,9 @@ func TestVersionCommand(t *testing.T) {
|
|||
if result["build"] == "" {
|
||||
t.Error("Expected build field to be non-empty")
|
||||
}
|
||||
// Verify cgo field is present and true (test file has //go:build cgo)
|
||||
if cgo, ok := result["cgo"]; !ok {
|
||||
t.Error("Expected cgo field to be present")
|
||||
} else if cgo != true {
|
||||
t.Errorf("Expected cgo=true in CGO build, got %v", cgo)
|
||||
// cgo field removed — server-only operation, no CGO bifurcation
|
||||
if _, ok := result["cgo"]; ok {
|
||||
t.Error("cgo field should no longer be present in version output")
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue