diff --git a/CHANGELOG.md b/CHANGELOG.md index c2ed0c8ed..25d9d1e42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -133,6 +133,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 its backend's lifecycle — it starts on demand and `bd dolt stop` shuts it down. Direct-server and embedded workspaces are unaffected. +- **`bd info` honors `doctor.suppress.git-hooks`** + ([#6027](https://github.com/gastownhall/beads/issues/6027)). `bd info` + printed the "Git hooks not installed" / "outdated" warning unconditionally, + so suppressing the check for `bd doctor` left it nagging on every `bd info`. + It now reads the same `doctor.suppress.*` config through the doctor helper + and skips the warning when `git-hooks` is suppressed. `bd info --json` never + carried the warning and is unchanged. + - **`bd dolt status` tells the truth on a proxied workspace.** It read the classic PID file, which proxied mode never writes, and so reported `Dolt server: not running` while the proxy was serving CRUD — the wrong answer diff --git a/cmd/bd/doctor/suppress.go b/cmd/bd/doctor/suppress.go index 83083d7cb..60a52217c 100644 --- a/cmd/bd/doctor/suppress.go +++ b/cmd/bd/doctor/suppress.go @@ -45,14 +45,21 @@ func GetSuppressedChecksWithStore(ss *SharedStore) map[string]bool { } func getSuppressedChecksFromStore(store *dolt.DoltStore) map[string]bool { - suppressed := make(map[string]bool) - ctx := context.Background() allConfig, err := store.GetAllConfig(ctx) if err != nil { - return suppressed + return make(map[string]bool) } + return SuppressedChecksFromConfig(allConfig) +} + +// SuppressedChecksFromConfig extracts the suppressed check slugs from an +// already-loaded config map, for callers outside bd doctor that hold their +// own store (e.g. bd info, GH#6027). +func SuppressedChecksFromConfig(allConfig map[string]string) map[string]bool { + suppressed := make(map[string]bool) + for key, value := range allConfig { if strings.HasPrefix(key, SuppressConfigPrefix) && strings.ToLower(value) == "true" { slug := key[len(SuppressConfigPrefix):] diff --git a/cmd/bd/info.go b/cmd/bd/info.go index e8fee1860..daf9d21c6 100644 --- a/cmd/bd/info.go +++ b/cmd/bd/info.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/spf13/cobra" + "github.com/steveyegge/beads/cmd/bd/doctor" "github.com/steveyegge/beads/internal/metrics" "github.com/steveyegge/beads/internal/types" "github.com/steveyegge/beads/internal/workapi" @@ -64,6 +65,8 @@ Examples: "mode": "direct", } + suppressHookWarning := false + if store != nil { ctx := rootCtx @@ -86,6 +89,8 @@ Examples: if filtered := workapi.FilterSettingsEnumeration(configMap); len(filtered) > 0 { info["config"] = filtered } + // GH#6027: honor the same doctor.suppress.git-hooks bd doctor does. + suppressHookWarning = doctor.SuppressedChecksFromConfig(configMap)[doctor.CheckNameToSlug("Git Hooks")] } if schemaFlag { @@ -98,7 +103,7 @@ Examples: } } - return renderInfo(info, schemaFlag, absDBPath) + return renderInfo(info, schemaFlag, absDBPath, suppressHookWarning) }, } @@ -140,7 +145,7 @@ func buildInfoSchema(schemaVersion, prefix string, issues []*types.Issue) map[st } } -func renderInfo(info map[string]interface{}, schemaFlag bool, absDBPath string) error { +func renderInfo(info map[string]interface{}, schemaFlag bool, absDBPath string, suppressHookWarning bool) error { if jsonOutput { return outputJSON(info) } @@ -172,9 +177,11 @@ func renderInfo(info map[string]interface{}, schemaFlag bool, absDBPath string) } } - hookStatuses := CheckGitHooks() - if warning := FormatHookWarnings(hookStatuses); warning != "" { - fmt.Printf("\n%s\n", warning) + if !suppressHookWarning { + hookStatuses := CheckGitHooks() + if warning := FormatHookWarnings(hookStatuses); warning != "" { + fmt.Printf("\n%s\n", warning) + } } fmt.Println() diff --git a/cmd/bd/info_embedded_test.go b/cmd/bd/info_embedded_test.go index c91d6207b..029e7a888 100644 --- a/cmd/bd/info_embedded_test.go +++ b/cmd/bd/info_embedded_test.go @@ -141,6 +141,35 @@ func TestEmbeddedInfo(t *testing.T) { }) } +// TestEmbeddedInfoSuppressGitHooks pins GH#6027: bd info must honor +// doctor.suppress.git-hooks the same way bd doctor does, instead of printing +// the missing-hooks warning unconditionally. +func TestEmbeddedInfoSuppressGitHooks(t *testing.T) { + if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" { + t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run embedded dolt integration tests") + } + t.Parallel() + + bd := buildEmbeddedBD(t) + dir, _, _ := bdInit(t, bd, "--prefix", "ih") + bdRunOK(t, bd, dir, "hooks", "uninstall") + + const hookWarning = "Git hooks not installed" + if out := bdInfo(t, bd, dir); !strings.Contains(out, hookWarning) { + t.Fatalf("precondition: expected %q with hooks uninstalled:\n%s", hookWarning, out) + } + + bdConfig(t, bd, dir, "set", "doctor.suppress.git-hooks", "true") + if out := bdInfo(t, bd, dir); strings.Contains(out, hookWarning) { + t.Errorf("doctor.suppress.git-hooks=true should hide %q:\n%s", hookWarning, out) + } + + bdConfig(t, bd, dir, "set", "doctor.suppress.git-hooks", "false") + if out := bdInfo(t, bd, dir); !strings.Contains(out, hookWarning) { + t.Errorf("doctor.suppress.git-hooks=false should keep %q:\n%s", hookWarning, out) + } +} + // TestEmbeddedInfoConcurrent exercises info operations concurrently. func TestEmbeddedInfoConcurrent(t *testing.T) { if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" { diff --git a/cmd/bd/info_proxied_server.go b/cmd/bd/info_proxied_server.go index 01ce2fee8..a53a4e894 100644 --- a/cmd/bd/info_proxied_server.go +++ b/cmd/bd/info_proxied_server.go @@ -3,6 +3,7 @@ package main import ( "context" + "github.com/steveyegge/beads/cmd/bd/doctor" "github.com/steveyegge/beads/internal/types" "github.com/steveyegge/beads/internal/workapi" ) @@ -21,6 +22,8 @@ func runInfoProxiedServer(ctx context.Context, schemaFlag bool) error { "mode": "proxied-server", } + suppressHookWarning := false + page, err := uw.IssueUseCase().SearchIssues(ctx, "", types.IssueFilter{}) var issues []*types.Issue if err == nil { @@ -42,6 +45,8 @@ func runInfoProxiedServer(ctx context.Context, schemaFlag bool) error { if filtered := workapi.FilterSettingsEnumeration(configMap); len(filtered) > 0 { info["config"] = filtered } + // GH#6027: honor the same doctor.suppress.git-hooks bd doctor does. + suppressHookWarning = doctor.SuppressedChecksFromConfig(configMap)[doctor.CheckNameToSlug("Git Hooks")] } if schemaFlag { @@ -53,5 +58,5 @@ func runInfoProxiedServer(ctx context.Context, schemaFlag bool) error { info["schema"] = buildInfoSchema(schemaVersion, prefix, issues) } - return renderInfo(info, schemaFlag, absDBPath) + return renderInfo(info, schemaFlag, absDBPath, suppressHookWarning) }