Files
beads/cmd/bd/doctor/fix/sync.go
Steve Yegge 9f76cfda01 refactor: remove all deletions.jsonl code (bd-fom)
Complete removal of the legacy deletions.jsonl manifest system.
Tombstones are now the sole deletion mechanism.

Removed:
- internal/deletions/ - entire package
- cmd/bd/deleted.go - deleted command
- cmd/bd/doctor/fix/deletions.go - HydrateDeletionsManifest
- Tests for all removed functionality

Cleaned:
- cmd/bd/sync.go - removed sanitize, auto-compact
- cmd/bd/delete.go - removed dual-writes
- cmd/bd/doctor.go - removed checkDeletionsManifest
- internal/importer/importer.go - removed deletions checks
- internal/syncbranch/worktree.go - removed deletions merge
- cmd/bd/integrity.go - updated validation (warn-only on decrease)

Files removed: 12
Lines removed: ~7500

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 14:20:49 -08:00

59 lines
1.3 KiB
Go

package fix
import (
"fmt"
"os"
"os/exec"
"path/filepath"
)
// DBJSONLSync fixes database-JSONL sync issues by running bd sync --import-only
func DBJSONLSync(path string) error {
// Validate workspace
if err := validateBeadsWorkspace(path); err != nil {
return err
}
beadsDir := filepath.Join(path, ".beads")
// Check if both database and JSONL exist
dbPath := filepath.Join(beadsDir, "beads.db")
jsonlPath := filepath.Join(beadsDir, "issues.jsonl")
beadsJSONLPath := filepath.Join(beadsDir, "beads.jsonl")
hasDB := false
if _, err := os.Stat(dbPath); err == nil {
hasDB = true
}
hasJSONL := false
if _, err := os.Stat(jsonlPath); err == nil {
hasJSONL = true
} else if _, err := os.Stat(beadsJSONLPath); err == nil {
hasJSONL = true
}
if !hasDB || !hasJSONL {
// Nothing to sync
return nil
}
// Get bd binary path
bdBinary, err := getBdBinary()
if err != nil {
return err
}
// Run bd sync --import-only to import JSONL updates
cmd := exec.Command(bdBinary, "sync", "--import-only") // #nosec G204 -- bdBinary from validated executable path
cmd.Dir = path // Set working directory without changing process dir
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to sync database with JSONL: %w", err)
}
return nil
}