fix(doctor): improve messaging for detection-only hook managers (bd-par1)
When bd doctor detects hook managers we can't fully check (pre-commit,
overcommit, yorkie, simple-git-hooks), it now shows an informational
message instead of a warning:
✓ pre-commit detected (cannot verify bd integration)
└─ Ensure your hook config calls 'bd hooks run <hook>'
Previously it incorrectly warned that these managers were "not calling bd"
when we simply couldn't verify their config.
Changes:
- Add DetectionOnly field to HookIntegrationStatus
- Set DetectionOnly=true for unsupported managers in CheckExternalHookManagerIntegration
- Update CheckGitHooks and CheckSyncBranchHookCompatibility to show
informational message for detection-only managers
- Add test coverage for DetectionOnly behavior
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -608,11 +608,12 @@ func slicesEqual(a, b []string) bool {
|
||||
|
||||
func TestCheckExternalHookManagerIntegration(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
setup func(dir string) error
|
||||
expectNil bool
|
||||
expectManager string
|
||||
expectConfigured bool
|
||||
name string
|
||||
setup func(dir string) error
|
||||
expectNil bool
|
||||
expectManager string
|
||||
expectConfigured bool
|
||||
expectDetectionOnly bool
|
||||
}{
|
||||
{
|
||||
name: "no managers",
|
||||
@@ -631,9 +632,10 @@ func TestCheckExternalHookManagerIntegration(t *testing.T) {
|
||||
`
|
||||
return os.WriteFile(filepath.Join(dir, "lefthook.yml"), []byte(config), 0644)
|
||||
},
|
||||
expectNil: false,
|
||||
expectManager: "lefthook",
|
||||
expectConfigured: true,
|
||||
expectNil: false,
|
||||
expectManager: "lefthook",
|
||||
expectConfigured: true,
|
||||
expectDetectionOnly: false,
|
||||
},
|
||||
{
|
||||
name: "husky with bd integration",
|
||||
@@ -644,18 +646,20 @@ func TestCheckExternalHookManagerIntegration(t *testing.T) {
|
||||
}
|
||||
return os.WriteFile(filepath.Join(huskyDir, "pre-commit"), []byte("#!/bin/sh\nbd hooks run pre-commit\n"), 0755)
|
||||
},
|
||||
expectNil: false,
|
||||
expectManager: "husky",
|
||||
expectConfigured: true,
|
||||
expectNil: false,
|
||||
expectManager: "husky",
|
||||
expectConfigured: true,
|
||||
expectDetectionOnly: false,
|
||||
},
|
||||
{
|
||||
name: "unsupported manager (pre-commit framework)",
|
||||
setup: func(dir string) error {
|
||||
return os.WriteFile(filepath.Join(dir, ".pre-commit-config.yaml"), []byte("repos:\n"), 0644)
|
||||
},
|
||||
expectNil: false,
|
||||
expectManager: "pre-commit",
|
||||
expectConfigured: false,
|
||||
expectNil: false,
|
||||
expectManager: "pre-commit",
|
||||
expectConfigured: false,
|
||||
expectDetectionOnly: true,
|
||||
},
|
||||
{
|
||||
name: "lefthook without bd",
|
||||
@@ -667,9 +671,10 @@ func TestCheckExternalHookManagerIntegration(t *testing.T) {
|
||||
`
|
||||
return os.WriteFile(filepath.Join(dir, "lefthook.yml"), []byte(config), 0644)
|
||||
},
|
||||
expectNil: false,
|
||||
expectManager: "lefthook",
|
||||
expectConfigured: false,
|
||||
expectNil: false,
|
||||
expectManager: "lefthook",
|
||||
expectConfigured: false,
|
||||
expectDetectionOnly: false, // lefthook IS supported, we can verify its config
|
||||
},
|
||||
}
|
||||
|
||||
@@ -700,6 +705,10 @@ func TestCheckExternalHookManagerIntegration(t *testing.T) {
|
||||
if result.Configured != tt.expectConfigured {
|
||||
t.Errorf("Configured: expected %v, got %v", tt.expectConfigured, result.Configured)
|
||||
}
|
||||
|
||||
if result.DetectionOnly != tt.expectDetectionOnly {
|
||||
t.Errorf("DetectionOnly: expected %v, got %v", tt.expectDetectionOnly, result.DetectionOnly)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user