diff --git a/cmd/bd/hook.go b/cmd/bd/hook.go index d9e21a99..e7ef8ba7 100644 --- a/cmd/bd/hook.go +++ b/cmd/bd/hook.go @@ -553,6 +553,7 @@ func hookPostMergeDolt(beadsDir string) int { Merge(ctx context.Context, branch string) error Commit(ctx context.Context, message string) error CurrentBranch(ctx context.Context) (string, error) + DeleteBranch(ctx context.Context, branch string) error }) if !ok { // Not a Dolt store with version control, use regular import @@ -613,7 +614,11 @@ func hookPostMergeDolt(beadsDir string) int { // This is expected, not an error } - // TODO: Delete import branch (need to add DeleteBranch method to DoltStore) + // Clean up import branch + if err := doltStore.DeleteBranch(ctx, importBranch); err != nil { + // Non-fatal - branch cleanup is best-effort + fmt.Fprintf(os.Stderr, "Warning: could not delete import branch %s: %v\n", importBranch, err) + } return 0 } diff --git a/internal/storage/dolt/store.go b/internal/storage/dolt/store.go index 83de93aa..e5fffaf7 100644 --- a/internal/storage/dolt/store.go +++ b/internal/storage/dolt/store.go @@ -361,6 +361,15 @@ func (s *DoltStore) CurrentBranch(ctx context.Context) (string, error) { return branch, nil } +// DeleteBranch deletes a branch (used to clean up import branches) +func (s *DoltStore) DeleteBranch(ctx context.Context, branch string) error { + _, err := s.db.ExecContext(ctx, "CALL DOLT_BRANCH('-D', ?)", branch) + if err != nil { + return fmt.Errorf("failed to delete branch %s: %w", branch, err) + } + return nil +} + // Log returns recent commit history func (s *DoltStore) Log(ctx context.Context, limit int) ([]CommitInfo, error) { rows, err := s.db.QueryContext(ctx, `