fix: Show warning when config.yaml overrides database config (bd-20j)

bd config list now shows a warning when config.yaml or environment
variables override database settings. This addresses the confusion when
sync.branch from config.yaml takes precedence over the database value.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-29 14:03:31 -08:00
parent 9eb61f9dd0
commit 2c57d41275

View File

@@ -209,9 +209,36 @@ var configListCmd = &cobra.Command{
for _, k := range keys {
fmt.Printf(" %s = %s\n", k, config[k])
}
// Check for config.yaml overrides that take precedence (bd-20j)
// This helps diagnose when effective config differs from database config
showConfigYAMLOverrides(config)
},
}
// showConfigYAMLOverrides warns when config.yaml or env vars override database settings.
// This addresses the confusion when `bd config list` shows one value but the effective
// value used by commands is different due to higher-priority config sources.
func showConfigYAMLOverrides(dbConfig map[string]string) {
var overrides []string
// Check sync.branch - can be overridden by BEADS_SYNC_BRANCH env var or config.yaml sync-branch
if dbSyncBranch, ok := dbConfig[syncbranch.ConfigKey]; ok && dbSyncBranch != "" {
effectiveBranch := syncbranch.GetFromYAML()
if effectiveBranch != "" && effectiveBranch != dbSyncBranch {
overrides = append(overrides, fmt.Sprintf(" sync.branch: database has '%s' but effective value is '%s' (from config.yaml or env)", dbSyncBranch, effectiveBranch))
}
}
if len(overrides) > 0 {
fmt.Println("\n⚠ Config overrides (higher priority sources):")
for _, o := range overrides {
fmt.Println(o)
}
fmt.Println("\nNote: config.yaml and environment variables take precedence over database config.")
}
}
var configUnsetCmd = &cobra.Command{
Use: "unset <key>",
Short: "Delete a configuration value",