fix: remove deprecated commands, dead SQLite code, and legacy scripts
Remove Beads Classic remnants that are no longer needed now that the system is pure Dolt: - Delete deprecated commands: sync, template (cmds only), thanks (cmd only), detect-pollution (cmd only), admin aliases, comment alias - Remove dead sqliteBackendWarning() and all 7 unreachable call sites (GetBackend() always returns "dolt") - Remove sqliteIntegrityRecovery() from fix package - Delete legacy test scripts: test_wsl2_wal.sh, test_issue_gh1224.sh, migrate-audit.sh - Remove SQLite-specific test functions from doctor tests Utility functions shared with active code are preserved (e.g., TemplateSubgraph, isTestIssue, printThanksPage). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
30a3be9b76
commit
5e834bff6a
15 changed files with 13 additions and 1076 deletions
|
|
@ -1,57 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Hidden aliases for backwards compatibility.
|
||||
// These commands forward to their admin subcommand equivalents.
|
||||
// They are hidden from help output but still work for scripts/muscle memory.
|
||||
|
||||
var cleanupAliasCmd = &cobra.Command{
|
||||
Use: "cleanup",
|
||||
Hidden: true,
|
||||
Deprecated: "use 'bd admin cleanup' instead (will be removed in v1.0.0)",
|
||||
Short: "Alias for 'bd admin cleanup' (deprecated)",
|
||||
Long: cleanupCmd.Long,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cleanupCmd.Run(cmd, args)
|
||||
},
|
||||
}
|
||||
|
||||
// NOTE: The top-level "compact" command slot is now used by the Dolt commit
|
||||
// compaction command (compact_dolt.go). The old issue-level compaction lives
|
||||
// at "bd admin compact".
|
||||
|
||||
var resetAliasCmd = &cobra.Command{
|
||||
Use: "reset",
|
||||
Hidden: true,
|
||||
Deprecated: "use 'bd admin reset' instead (will be removed in v1.0.0)",
|
||||
Short: "Alias for 'bd admin reset' (deprecated)",
|
||||
Long: resetCmd.Long,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
resetCmd.Run(cmd, args)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Copy flags from original commands to aliases, binding to same global variables
|
||||
// This ensures that when the alias command runs, the global flag variables are set correctly
|
||||
|
||||
// Cleanup alias flags - these read from cmd.Flags() in the Run function
|
||||
cleanupAliasCmd.Flags().BoolP("force", "f", false, "Actually delete (without this flag, shows error)")
|
||||
cleanupAliasCmd.Flags().Bool("dry-run", false, "Preview what would be deleted without making changes")
|
||||
cleanupAliasCmd.Flags().Bool("cascade", false, "Recursively delete all dependent issues")
|
||||
cleanupAliasCmd.Flags().Int("older-than", 0, "Only delete issues closed more than N days ago (0 = all closed issues)")
|
||||
cleanupAliasCmd.Flags().Bool("ephemeral", false, "Only delete closed wisps (transient molecules)")
|
||||
|
||||
// NOTE: compactAliasCmd removed — "compact" slot now used by compact_dolt.go
|
||||
|
||||
// Reset alias flags - these read from cmd.Flags() in the Run function
|
||||
resetAliasCmd.Flags().Bool("force", false, "Actually perform the reset (required)")
|
||||
|
||||
// Register hidden aliases on root command
|
||||
rootCmd.AddCommand(cleanupAliasCmd)
|
||||
// NOTE: compactAliasCmd removed — "compact" slot now used by compact_dolt.go
|
||||
rootCmd.AddCommand(resetAliasCmd)
|
||||
}
|
||||
|
|
@ -148,34 +148,17 @@ Examples:
|
|||
},
|
||||
}
|
||||
|
||||
// commentCmd is a hidden top-level alias for commentsAddCmd (backwards compat)
|
||||
var commentCmd = &cobra.Command{
|
||||
Use: "comment [issue-id] [text]",
|
||||
Short: "Add a comment to an issue (alias for 'comments add')",
|
||||
Long: `Add a comment to an issue. This is an alias for 'bd comments add'.`,
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
Run: commentsAddCmd.Run,
|
||||
Hidden: true,
|
||||
Deprecated: "use 'bd comments add' instead (will be removed in v1.0.0)",
|
||||
}
|
||||
|
||||
func init() {
|
||||
commentsCmd.AddCommand(commentsAddCmd)
|
||||
commentsCmd.Flags().Bool("local-time", false, "Show timestamps in local time instead of UTC")
|
||||
commentsAddCmd.Flags().StringP("file", "f", "", "Read comment text from file")
|
||||
commentsAddCmd.Flags().StringP("author", "a", "", "Add author to comment")
|
||||
|
||||
// Add the same flags to the alias
|
||||
commentCmd.Flags().StringP("file", "f", "", "Read comment text from file")
|
||||
commentCmd.Flags().StringP("author", "a", "", "Add author to comment")
|
||||
|
||||
// Issue ID completions
|
||||
commentsCmd.ValidArgsFunction = issueIDCompletion
|
||||
commentsAddCmd.ValidArgsFunction = issueIDCompletion
|
||||
commentCmd.ValidArgsFunction = issueIDCompletion
|
||||
|
||||
rootCmd.AddCommand(commentsCmd)
|
||||
rootCmd.AddCommand(commentCmd)
|
||||
}
|
||||
|
||||
func isUnknownOperationError(err error) bool {
|
||||
|
|
|
|||
|
|
@ -94,10 +94,9 @@ func TestCommentsSuite(t *testing.T) {
|
|||
})
|
||||
})
|
||||
|
||||
t.Run("CommentAlias", func(t *testing.T) {
|
||||
// Create test issue
|
||||
t.Run("AddComment", func(t *testing.T) {
|
||||
issue := &types.Issue{
|
||||
Title: "Test Issue for Alias",
|
||||
Title: "Test Issue for Comment",
|
||||
Description: "Test description",
|
||||
Priority: 1,
|
||||
IssueType: types.TypeBug,
|
||||
|
|
@ -108,30 +107,7 @@ func TestCommentsSuite(t *testing.T) {
|
|||
t.Fatalf("Failed to create issue: %v", err)
|
||||
}
|
||||
|
||||
t.Run("comment alias shares Run function with comments add", func(t *testing.T) {
|
||||
// This verifies that commentCmd reuses commentsAddCmd.Run
|
||||
if commentCmd.Run == nil {
|
||||
t.Error("commentCmd.Run is nil")
|
||||
}
|
||||
|
||||
if commentsAddCmd.Run == nil {
|
||||
t.Error("commentsAddCmd.Run is nil")
|
||||
}
|
||||
|
||||
// Verify they share the same Run function (same memory address)
|
||||
// This is a compile-time guarantee from how we defined it
|
||||
// Just verify the command structure is set up correctly
|
||||
if commentCmd.Use != "comment [issue-id] [text]" {
|
||||
t.Errorf("Expected Use to be 'comment [issue-id] [text]', got %s", commentCmd.Use)
|
||||
}
|
||||
|
||||
if commentCmd.Short != "Add a comment to an issue (alias for 'comments add')" {
|
||||
t.Errorf("Unexpected Short description: %s", commentCmd.Short)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("comment added via storage API works", func(t *testing.T) {
|
||||
// Test direct storage API (which is what the command uses under the hood)
|
||||
comment, err := s.AddIssueComment(ctx, issue.ID, testUserAlice, "Test comment")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to add comment: %v", err)
|
||||
|
|
@ -141,7 +117,6 @@ func TestCommentsSuite(t *testing.T) {
|
|||
t.Errorf("Expected 'Test comment', got %s", comment.Text)
|
||||
}
|
||||
|
||||
// Verify via GetIssueComments
|
||||
comments, err := s.GetIssueComments(ctx, issue.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get comments: %v", err)
|
||||
|
|
|
|||
|
|
@ -7,169 +7,12 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
"github.com/steveyegge/beads/internal/ui"
|
||||
)
|
||||
|
||||
// showDetectPollutionDeprecationHint shows a hint about bd doctor consolidation
|
||||
func showDetectPollutionDeprecationHint() {
|
||||
fmt.Fprintln(os.Stderr, ui.RenderMuted("💡 Tip: Use 'bd doctor --check=pollution' instead (this command is deprecated)"))
|
||||
}
|
||||
|
||||
var detectPollutionCmd = &cobra.Command{
|
||||
Use: "detect-pollution",
|
||||
GroupID: "maint",
|
||||
Hidden: true, // deprecated, use 'bd doctor --check=pollution' instead
|
||||
Deprecated: "use 'bd doctor --check=pollution' instead (will be removed in v1.0.0)",
|
||||
Short: "Detect and optionally clean test issues from database",
|
||||
Long: `Detect test issues that leaked into production database using pattern matching.
|
||||
|
||||
This command finds issues that appear to be test data based on:
|
||||
- Titles starting with 'test', 'benchmark', 'sample', 'tmp', 'temp'
|
||||
- Sequential numbering patterns (test-1, test-2, ...)
|
||||
- Generic or missing descriptions
|
||||
- Created in rapid succession (potential script/automation artifacts)
|
||||
|
||||
USE CASES:
|
||||
- Cleaning up after testing in a production database
|
||||
- Identifying accidental test data from CI/automation
|
||||
- Database hygiene after development experiments
|
||||
- Quality checks before database backups
|
||||
|
||||
EXAMPLES:
|
||||
bd detect-pollution # Show potential test issues
|
||||
bd detect-pollution --clean # Delete test issues (with confirmation)
|
||||
bd detect-pollution --clean --yes # Delete without confirmation
|
||||
bd detect-pollution --json # Output in JSON format
|
||||
|
||||
NOTE: Review detected issues carefully before using --clean. False positives are possible.`,
|
||||
Run: func(cmd *cobra.Command, _ []string) {
|
||||
clean, _ := cmd.Flags().GetBool("clean")
|
||||
yes, _ := cmd.Flags().GetBool("yes")
|
||||
|
||||
ctx := rootCtx
|
||||
|
||||
// Get all issues
|
||||
allIssues, err := store.SearchIssues(ctx, "", types.IssueFilter{})
|
||||
if err != nil {
|
||||
FatalError("fetching issues: %v", err)
|
||||
}
|
||||
|
||||
// Detect pollution
|
||||
polluted := detectTestPollution(allIssues)
|
||||
|
||||
if len(polluted) == 0 {
|
||||
if !jsonOutput {
|
||||
fmt.Println("No test pollution detected!")
|
||||
} else {
|
||||
outputJSON(map[string]interface{}{
|
||||
"polluted_count": 0,
|
||||
"issues": []interface{}{},
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Categorize by confidence
|
||||
highConfidence := []pollutionResult{}
|
||||
mediumConfidence := []pollutionResult{}
|
||||
|
||||
for _, p := range polluted {
|
||||
if p.score >= 0.9 {
|
||||
highConfidence = append(highConfidence, p)
|
||||
} else {
|
||||
mediumConfidence = append(mediumConfidence, p)
|
||||
}
|
||||
}
|
||||
|
||||
if jsonOutput {
|
||||
result := map[string]interface{}{
|
||||
"polluted_count": len(polluted),
|
||||
"high_confidence": len(highConfidence),
|
||||
"medium_confidence": len(mediumConfidence),
|
||||
"issues": []map[string]interface{}{},
|
||||
}
|
||||
|
||||
for _, p := range polluted {
|
||||
result["issues"] = append(result["issues"].([]map[string]interface{}), map[string]interface{}{
|
||||
"id": p.issue.ID,
|
||||
"title": p.issue.Title,
|
||||
"score": p.score,
|
||||
"reasons": p.reasons,
|
||||
"created_at": p.issue.CreatedAt,
|
||||
})
|
||||
}
|
||||
|
||||
outputJSON(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Human-readable output
|
||||
fmt.Printf("Found %d potential test issues:\n\n", len(polluted))
|
||||
|
||||
if len(highConfidence) > 0 {
|
||||
fmt.Printf("High Confidence (score ≥ 0.9):\n")
|
||||
for _, p := range highConfidence {
|
||||
fmt.Printf(" %s: %q (score: %.2f)\n", p.issue.ID, p.issue.Title, p.score)
|
||||
for _, reason := range p.reasons {
|
||||
fmt.Printf(" - %s\n", reason)
|
||||
}
|
||||
}
|
||||
fmt.Printf(" (Total: %d issues)\n\n", len(highConfidence))
|
||||
}
|
||||
|
||||
if len(mediumConfidence) > 0 {
|
||||
fmt.Printf("Medium Confidence (score 0.7-0.9):\n")
|
||||
for _, p := range mediumConfidence {
|
||||
fmt.Printf(" %s: %q (score: %.2f)\n", p.issue.ID, p.issue.Title, p.score)
|
||||
for _, reason := range p.reasons {
|
||||
fmt.Printf(" - %s\n", reason)
|
||||
}
|
||||
}
|
||||
fmt.Printf(" (Total: %d issues)\n\n", len(mediumConfidence))
|
||||
}
|
||||
|
||||
if !clean {
|
||||
fmt.Printf("Run 'bd detect-pollution --clean' to delete these issues (with confirmation).\n")
|
||||
// Show hint about doctor consolidation
|
||||
showDetectPollutionDeprecationHint()
|
||||
return
|
||||
}
|
||||
|
||||
// Confirmation prompt
|
||||
if !yes {
|
||||
fmt.Printf("\nDelete %d test issues? [y/N] ", len(polluted))
|
||||
var response string
|
||||
_, _ = fmt.Scanln(&response)
|
||||
if strings.ToLower(response) != "y" {
|
||||
fmt.Println("Canceled.")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Backup to JSONL before deleting
|
||||
backupPath := ".beads/pollution-backup.jsonl"
|
||||
if err := backupPollutedIssues(polluted, backupPath); err != nil {
|
||||
FatalError("backing up issues: %v", err)
|
||||
}
|
||||
fmt.Printf("Backed up %d issues to %s\n", len(polluted), backupPath)
|
||||
|
||||
// Delete issues
|
||||
fmt.Printf("\nDeleting %d issues...\n", len(polluted))
|
||||
deleted := 0
|
||||
for _, p := range polluted {
|
||||
if err := deleteIssue(ctx, p.issue.ID); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error deleting %s: %v\n", p.issue.ID, err)
|
||||
continue
|
||||
}
|
||||
deleted++
|
||||
}
|
||||
|
||||
fmt.Printf("%s Deleted %d test issues\n", ui.RenderPass("✓"), deleted)
|
||||
fmt.Printf("\nCleanup complete. To restore, run: bd import %s\n", backupPath)
|
||||
},
|
||||
}
|
||||
// Pollution detection utilities used by doctor_pollution.go, create.go, and export.go.
|
||||
// The deprecated 'bd detect-pollution' command has been removed;
|
||||
// use 'bd doctor --check=pollution' instead.
|
||||
|
||||
type pollutionResult struct {
|
||||
issue *types.Issue
|
||||
|
|
@ -276,9 +119,3 @@ func backupPollutedIssues(polluted []pollutionResult, path string) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
detectPollutionCmd.Flags().Bool("clean", false, "Delete detected test issues")
|
||||
detectPollutionCmd.Flags().Bool("yes", false, "Skip confirmation prompt")
|
||||
rootCmd.AddCommand(detectPollutionCmd)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,11 +58,7 @@ func CheckDoltFormat(path string) DoctorCheck {
|
|||
|
||||
// CheckDatabaseVersion checks the database version and migration status
|
||||
func CheckDatabaseVersion(path string, cliVersion string) DoctorCheck {
|
||||
backend, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
if backend != configfile.BackendDolt {
|
||||
return sqliteBackendWarning("Database")
|
||||
}
|
||||
_, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
doltPath := getDatabasePath(beadsDir)
|
||||
if _, err := os.Stat(doltPath); os.IsNotExist(err) {
|
||||
|
|
@ -128,11 +124,7 @@ func CheckDatabaseVersion(path string, cliVersion string) DoctorCheck {
|
|||
|
||||
// CheckSchemaCompatibility checks if all required tables and columns are present
|
||||
func CheckSchemaCompatibility(path string) DoctorCheck {
|
||||
backend, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
if backend != configfile.BackendDolt {
|
||||
return sqliteBackendWarning("Schema Compatibility")
|
||||
}
|
||||
_, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
if info, err := os.Stat(getDatabasePath(beadsDir)); err != nil || !info.IsDir() {
|
||||
return DoctorCheck{
|
||||
|
|
@ -175,11 +167,7 @@ func CheckSchemaCompatibility(path string) DoctorCheck {
|
|||
|
||||
// CheckDatabaseIntegrity runs a basic integrity check on the database
|
||||
func CheckDatabaseIntegrity(path string) DoctorCheck {
|
||||
backend, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
if backend != configfile.BackendDolt {
|
||||
return sqliteBackendWarning("Database Integrity")
|
||||
}
|
||||
_, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
if info, err := os.Stat(getDatabasePath(beadsDir)); err != nil || !info.IsDir() {
|
||||
return DoctorCheck{
|
||||
|
|
@ -235,16 +223,6 @@ func FixDatabaseConfig(path string) error {
|
|||
return fix.DatabaseConfig(path)
|
||||
}
|
||||
|
||||
// sqliteBackendWarning returns a standard warning for legacy SQLite backends
|
||||
func sqliteBackendWarning(checkName string) DoctorCheck {
|
||||
return DoctorCheck{
|
||||
Name: checkName,
|
||||
Status: StatusWarning,
|
||||
Message: "SQLite backend detected",
|
||||
Fix: "Run 'bd migrate --to-dolt' to upgrade to Dolt backend",
|
||||
}
|
||||
}
|
||||
|
||||
// getDatabasePath returns the actual database directory path, respecting dolt_data_dir.
|
||||
// When dolt_data_dir is configured (e.g. ext4 redirect for WSL), the database lives
|
||||
// outside .beads/dolt/ — this function resolves the correct location.
|
||||
|
|
@ -284,11 +262,7 @@ func isNoDbModeConfigured(beadsDir string) bool {
|
|||
// irreversible. The user must make an explicit decision to delete their
|
||||
// closed issue history. We only provide guidance, never action.
|
||||
func CheckDatabaseSize(path string) DoctorCheck {
|
||||
backend, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
if backend != configfile.BackendDolt {
|
||||
return sqliteBackendWarning("Large Database")
|
||||
}
|
||||
_, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
doltPath := getDatabasePath(beadsDir)
|
||||
if _, err := os.Stat(doltPath); os.IsNotExist(err) {
|
||||
|
|
|
|||
|
|
@ -120,20 +120,3 @@ func TestCheckSchemaCompatibility(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckDatabaseIntegrity_EdgeCases(t *testing.T) {
|
||||
t.Skip("SQLite-specific edge cases (locked DB, read-only file); Dolt backend uses server connections")
|
||||
}
|
||||
|
||||
func TestSqliteBackendWarning(t *testing.T) {
|
||||
check := sqliteBackendWarning("Database")
|
||||
if check.Status != StatusWarning {
|
||||
t.Errorf("expected status %q, got %q", StatusWarning, check.Status)
|
||||
}
|
||||
if check.Message != "SQLite backend detected" {
|
||||
t.Errorf("expected message %q, got %q", "SQLite backend detected", check.Message)
|
||||
}
|
||||
if check.Fix == "" {
|
||||
t.Error("expected non-empty Fix field")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,16 +5,11 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/steveyegge/beads/internal/configfile"
|
||||
)
|
||||
|
||||
// DatabaseIntegrity attempts to recover from database corruption by:
|
||||
// 1. Backing up the corrupt database
|
||||
// 2. Re-initializing via bd init (which will clone from remote if configured)
|
||||
//
|
||||
// For Dolt backends: backs up .beads/dolt and reinitializes via bd init --force.
|
||||
// For SQLite backends: backs up the .db file and reinitializes via bd init.
|
||||
func DatabaseIntegrity(path string) error {
|
||||
if err := validateBeadsWorkspace(path); err != nil {
|
||||
return err
|
||||
|
|
@ -26,14 +21,7 @@ func DatabaseIntegrity(path string) error {
|
|||
}
|
||||
|
||||
beadsDir := filepath.Join(absPath, ".beads")
|
||||
|
||||
// Dolt backend: backup and reinitialize
|
||||
if cfg, err := configfile.Load(beadsDir); err == nil && cfg != nil && cfg.GetBackend() == configfile.BackendDolt {
|
||||
return doltIntegrityRecovery(absPath, beadsDir)
|
||||
}
|
||||
|
||||
// SQLite backend: backup and reinitialize
|
||||
return sqliteIntegrityRecovery(absPath, beadsDir)
|
||||
return doltIntegrityRecovery(absPath, beadsDir)
|
||||
}
|
||||
|
||||
// doltIntegrityRecovery backs up the corrupted Dolt database and reinitializes.
|
||||
|
|
@ -81,60 +69,3 @@ func doltIntegrityRecovery(path, beadsDir string) error {
|
|||
fmt.Printf(" Corrupted database preserved at: %s\n", filepath.Base(backupPath))
|
||||
return nil
|
||||
}
|
||||
|
||||
// sqliteIntegrityRecovery backs up the corrupted SQLite database and reinitializes.
|
||||
func sqliteIntegrityRecovery(path, beadsDir string) error {
|
||||
// Resolve database path
|
||||
var dbPath string
|
||||
if cfg, err := configfile.Load(beadsDir); err == nil && cfg != nil && cfg.Database != "" {
|
||||
dbPath = cfg.DatabasePath(beadsDir)
|
||||
} else {
|
||||
dbPath = filepath.Join(beadsDir, "beads.db")
|
||||
}
|
||||
|
||||
// Check if database exists
|
||||
if _, err := os.Stat(dbPath); os.IsNotExist(err) {
|
||||
return fmt.Errorf("no database to recover at %s", dbPath)
|
||||
}
|
||||
|
||||
// Back up corrupt DB and its sidecar files.
|
||||
ts := time.Now().UTC().Format("20060102T150405Z")
|
||||
backupDB := dbPath + "." + ts + ".corrupt.backup.db"
|
||||
if err := moveFile(dbPath, backupDB); err != nil {
|
||||
return fmt.Errorf("failed to back up database: %w", err)
|
||||
}
|
||||
for _, suffix := range []string{"-wal", "-shm", "-journal"} {
|
||||
sidecar := dbPath + suffix
|
||||
if _, err := os.Stat(sidecar); err == nil {
|
||||
_ = moveFile(sidecar, backupDB+suffix)
|
||||
}
|
||||
}
|
||||
|
||||
// Reinitialize via bd init
|
||||
bdBinary, err := getBdBinary()
|
||||
if err != nil {
|
||||
// Restore backup on failure (database has already been moved)
|
||||
_ = moveFile(backupDB, dbPath)
|
||||
for _, suffix := range []string{"-wal", "-shm", "-journal"} {
|
||||
sidecar := backupDB + suffix
|
||||
if _, err := os.Stat(sidecar); err == nil {
|
||||
_ = moveFile(sidecar, dbPath+suffix)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf(" Reinitializing database\n")
|
||||
initCmd := newBdCmd(bdBinary, "init", "--force", "-q", "--skip-hooks")
|
||||
initCmd.Dir = path
|
||||
initCmd.Stdout = os.Stdout
|
||||
initCmd.Stderr = os.Stderr
|
||||
|
||||
if err := initCmd.Run(); err != nil {
|
||||
// Best-effort rollback
|
||||
_ = copyFile(backupDB, dbPath)
|
||||
return fmt.Errorf("failed to reinitialize database: %w (backup: %s)", err, backupDB)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,18 +11,13 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/steveyegge/beads/internal/beads"
|
||||
"github.com/steveyegge/beads/internal/configfile"
|
||||
"github.com/steveyegge/beads/internal/git"
|
||||
"github.com/steveyegge/beads/internal/storage/dolt"
|
||||
)
|
||||
|
||||
// CheckIDFormat checks whether issues use hash-based or sequential IDs
|
||||
func CheckIDFormat(path string) DoctorCheck {
|
||||
backend, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
if backend != configfile.BackendDolt {
|
||||
return sqliteBackendWarning("Issue IDs")
|
||||
}
|
||||
_, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
doltPath := getDatabasePath(beadsDir)
|
||||
if _, err := os.Stat(doltPath); os.IsNotExist(err) {
|
||||
|
|
@ -100,11 +95,7 @@ func CheckIDFormat(path string) DoctorCheck {
|
|||
|
||||
// CheckDependencyCycles checks for circular dependencies in the issue graph
|
||||
func CheckDependencyCycles(path string) DoctorCheck {
|
||||
backend, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
if backend != configfile.BackendDolt {
|
||||
return sqliteBackendWarning("Dependency Cycles")
|
||||
}
|
||||
_, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
doltPath := getDatabasePath(beadsDir)
|
||||
if _, err := os.Stat(doltPath); os.IsNotExist(err) {
|
||||
|
|
@ -292,11 +283,7 @@ func CheckDeletionsManifest(path string) DoctorCheck {
|
|||
// This detects when a .beads directory was copied from another repo or when
|
||||
// the git remote URL changed. A mismatch can cause data loss during sync.
|
||||
func CheckRepoFingerprint(path string) DoctorCheck {
|
||||
backend, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
if backend != configfile.BackendDolt {
|
||||
return sqliteBackendWarning("Repo Fingerprint")
|
||||
}
|
||||
_, beadsDir := getBackendAndBeadsDir(path)
|
||||
|
||||
if info, err := os.Stat(getDatabasePath(beadsDir)); err != nil || !info.IsDir() {
|
||||
return DoctorCheck{
|
||||
|
|
|
|||
|
|
@ -47,17 +47,6 @@ func init() {
|
|||
// Add as subcommands of dep
|
||||
depCmd.AddCommand(relateCmd)
|
||||
depCmd.AddCommand(unrelateCmd)
|
||||
|
||||
// Backwards compatibility aliases at root level (hidden)
|
||||
relateAliasCmd := *relateCmd
|
||||
relateAliasCmd.Hidden = true
|
||||
relateAliasCmd.Deprecated = "use 'bd dep relate' instead (will be removed in v1.0.0)"
|
||||
rootCmd.AddCommand(&relateAliasCmd)
|
||||
|
||||
unrelateAliasCmd := *unrelateCmd
|
||||
unrelateAliasCmd.Hidden = true
|
||||
unrelateAliasCmd.Deprecated = "use 'bd dep unrelate' instead (will be removed in v1.0.0)"
|
||||
rootCmd.AddCommand(&unrelateAliasCmd)
|
||||
}
|
||||
|
||||
func runRelate(cmd *cobra.Command, args []string) error {
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// syncCmd is a deprecated no-op that directs users to bd dolt push/pull.
|
||||
var syncCmd = &cobra.Command{
|
||||
Use: "sync",
|
||||
GroupID: "sync",
|
||||
Short: "Deprecated: use 'bd dolt push' and 'bd dolt pull' instead",
|
||||
Long: `bd sync is deprecated and is now a no-op.
|
||||
|
||||
Use Dolt remote commands directly:
|
||||
bd dolt push Push to Dolt remote
|
||||
bd dolt pull Pull from Dolt remote`,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
fmt.Println("bd sync is deprecated. Use 'bd dolt push' and 'bd dolt pull' instead.")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Keep all legacy flags so old invocations don't error out.
|
||||
syncCmd.Flags().StringP("message", "m", "", "Deprecated: no-op")
|
||||
syncCmd.Flags().Bool("dry-run", false, "Deprecated: no-op")
|
||||
syncCmd.Flags().Bool("no-push", false, "Deprecated: no-op")
|
||||
syncCmd.Flags().Bool("import", false, "Deprecated: use 'bd import' instead")
|
||||
syncCmd.Flags().Bool("import-only", false, "Deprecated: use 'bd import' instead")
|
||||
syncCmd.Flags().Bool("export", false, "Deprecated: use 'bd export' instead")
|
||||
syncCmd.Flags().Bool("flush-only", false, "Deprecated: no-op")
|
||||
syncCmd.Flags().Bool("pull", false, "Deprecated: use 'bd dolt pull' instead")
|
||||
syncCmd.Flags().Bool("no-git-history", false, "Deprecated: no-op")
|
||||
syncCmd.Flags().BoolVar(&jsonOutput, "json", false, "Output in JSON format")
|
||||
rootCmd.AddCommand(syncCmd)
|
||||
}
|
||||
|
|
@ -7,12 +7,10 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/beads/internal/formula"
|
||||
"github.com/steveyegge/beads/internal/storage"
|
||||
"github.com/steveyegge/beads/internal/storage/dolt"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
"github.com/steveyegge/beads/internal/ui"
|
||||
"github.com/steveyegge/beads/internal/utils"
|
||||
)
|
||||
|
||||
|
|
@ -64,251 +62,6 @@ type CloneOptions struct {
|
|||
// bondedIDPattern validates bonded IDs (alphanumeric, dash, underscore, dot)
|
||||
var bondedIDPattern = regexp.MustCompile(`^[a-zA-Z0-9_.-]+$`)
|
||||
|
||||
var templateCmd = &cobra.Command{
|
||||
Use: "template",
|
||||
GroupID: "setup",
|
||||
Short: "Manage issue templates",
|
||||
Deprecated: "use 'bd mol' instead (will be removed in v1.0.0)",
|
||||
Long: `Manage Beads templates for creating issue hierarchies.
|
||||
|
||||
Templates are epics with the "template" label. They can have child issues
|
||||
with {{variable}} placeholders that get substituted during instantiation.
|
||||
|
||||
To create a template:
|
||||
1. Create an epic with child issues
|
||||
2. Add the 'template' label: bd label add <epic-id> template
|
||||
3. Use {{variable}} placeholders in titles/descriptions
|
||||
|
||||
To use a template:
|
||||
bd template instantiate <id> --var key=value`,
|
||||
}
|
||||
|
||||
var templateListCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List available templates",
|
||||
Deprecated: "use 'bd formula list' instead (will be removed in v1.0.0)",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx := rootCtx
|
||||
var beadsTemplates []*types.Issue
|
||||
|
||||
if store != nil {
|
||||
var err error
|
||||
beadsTemplates, err = store.GetIssuesByLabel(ctx, BeadsTemplateLabel)
|
||||
if err != nil {
|
||||
FatalError("loading templates: %v", err)
|
||||
}
|
||||
} else {
|
||||
FatalError("no database connection")
|
||||
}
|
||||
|
||||
if jsonOutput {
|
||||
outputJSON(beadsTemplates)
|
||||
return
|
||||
}
|
||||
|
||||
// Human-readable output
|
||||
if len(beadsTemplates) == 0 {
|
||||
fmt.Println("No templates available.")
|
||||
fmt.Println("\nTo create a template:")
|
||||
fmt.Println(" 1. Create an epic with child issues")
|
||||
fmt.Println(" 2. Add the 'template' label: bd label add <epic-id> template")
|
||||
fmt.Println(" 3. Use {{variable}} placeholders in titles/descriptions")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", ui.RenderPass("Templates (for bd template instantiate):"))
|
||||
for _, tmpl := range beadsTemplates {
|
||||
vars := extractVariables(tmpl.Title + " " + tmpl.Description)
|
||||
varStr := ""
|
||||
if len(vars) > 0 {
|
||||
varStr = fmt.Sprintf(" (vars: %s)", strings.Join(vars, ", "))
|
||||
}
|
||||
fmt.Printf(" %s: %s%s\n", ui.RenderAccent(tmpl.ID), tmpl.Title, varStr)
|
||||
}
|
||||
fmt.Println()
|
||||
},
|
||||
}
|
||||
|
||||
var templateShowCmd = &cobra.Command{
|
||||
Use: "show <template-id>",
|
||||
Short: "Show template details",
|
||||
Deprecated: "use 'bd mol show' instead (will be removed in v1.0.0)",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx := rootCtx
|
||||
var templateID string
|
||||
|
||||
if store != nil {
|
||||
var err error
|
||||
templateID, err = utils.ResolvePartialID(ctx, store, args[0])
|
||||
if err != nil {
|
||||
FatalError("template '%s' not found", args[0])
|
||||
}
|
||||
} else {
|
||||
FatalError("no database connection")
|
||||
}
|
||||
|
||||
// Load and show Beads template
|
||||
var subgraph *TemplateSubgraph
|
||||
var err error
|
||||
subgraph, err = loadTemplateSubgraph(ctx, store, templateID)
|
||||
if err != nil {
|
||||
FatalError("loading template: %v", err)
|
||||
}
|
||||
|
||||
showBeadsTemplate(subgraph)
|
||||
},
|
||||
}
|
||||
|
||||
func showBeadsTemplate(subgraph *TemplateSubgraph) {
|
||||
if jsonOutput {
|
||||
outputJSON(map[string]interface{}{
|
||||
"root": subgraph.Root,
|
||||
"issues": subgraph.Issues,
|
||||
"dependencies": subgraph.Dependencies,
|
||||
"variables": extractAllVariables(subgraph),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("\n%s Template: %s\n", ui.RenderAccent("📋"), subgraph.Root.Title)
|
||||
fmt.Printf(" ID: %s\n", subgraph.Root.ID)
|
||||
fmt.Printf(" Issues: %d\n", len(subgraph.Issues))
|
||||
|
||||
// Show variables
|
||||
vars := extractAllVariables(subgraph)
|
||||
if len(vars) > 0 {
|
||||
fmt.Printf("\n%s Variables:\n", ui.RenderWarn("📝"))
|
||||
for _, v := range vars {
|
||||
fmt.Printf(" {{%s}}\n", v)
|
||||
}
|
||||
}
|
||||
|
||||
// Show structure
|
||||
fmt.Printf("\n%s Structure:\n", ui.RenderPass("🌲"))
|
||||
printTemplateTree(subgraph, subgraph.Root.ID, 0, true)
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
var templateInstantiateCmd = &cobra.Command{
|
||||
Use: "instantiate <template-id>",
|
||||
Short: "Create issues from a Beads template",
|
||||
Deprecated: "use 'bd mol bond' instead (will be removed in v1.0.0)",
|
||||
Long: `Instantiate a Beads template by cloning its subgraph and substituting variables.
|
||||
|
||||
Variables are specified with --var key=value flags. The template's {{key}}
|
||||
placeholders will be replaced with the corresponding values.
|
||||
|
||||
Example:
|
||||
bd template instantiate bd-abc123 --var version=1.2.0 --var date=2024-01-15`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
CheckReadonly("template instantiate")
|
||||
|
||||
ctx := rootCtx
|
||||
dryRun, _ := cmd.Flags().GetBool("dry-run")
|
||||
varFlags, _ := cmd.Flags().GetStringArray("var")
|
||||
assignee, _ := cmd.Flags().GetString("assignee")
|
||||
|
||||
// Parse variables
|
||||
vars := make(map[string]string)
|
||||
for _, v := range varFlags {
|
||||
parts := strings.SplitN(v, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
FatalError("invalid variable format '%s', expected 'key=value'", v)
|
||||
}
|
||||
vars[parts[0]] = parts[1]
|
||||
}
|
||||
|
||||
// Resolve template ID
|
||||
var templateID string
|
||||
if store != nil {
|
||||
var err error
|
||||
templateID, err = utils.ResolvePartialID(ctx, store, args[0])
|
||||
if err != nil {
|
||||
FatalError("resolving template ID %s: %v", args[0], err)
|
||||
}
|
||||
} else {
|
||||
FatalError("no database connection")
|
||||
}
|
||||
|
||||
// Load the template subgraph
|
||||
var subgraph *TemplateSubgraph
|
||||
var err error
|
||||
subgraph, err = loadTemplateSubgraph(ctx, store, templateID)
|
||||
if err != nil {
|
||||
FatalError("loading template: %v", err)
|
||||
}
|
||||
|
||||
// Check for missing variables
|
||||
requiredVars := extractAllVariables(subgraph)
|
||||
var missingVars []string
|
||||
for _, v := range requiredVars {
|
||||
if _, ok := vars[v]; !ok {
|
||||
missingVars = append(missingVars, v)
|
||||
}
|
||||
}
|
||||
if len(missingVars) > 0 {
|
||||
FatalErrorWithHint(
|
||||
fmt.Sprintf("missing required variables: %s", strings.Join(missingVars, ", ")),
|
||||
fmt.Sprintf("Provide them with: --var %s=<value>", missingVars[0]),
|
||||
)
|
||||
}
|
||||
|
||||
if dryRun {
|
||||
// Preview what would be created
|
||||
fmt.Printf("\nDry run: would create %d issues from template %s\n\n", len(subgraph.Issues), templateID)
|
||||
for _, issue := range subgraph.Issues {
|
||||
newTitle := substituteVariables(issue.Title, vars)
|
||||
suffix := ""
|
||||
if issue.ID == subgraph.Root.ID && assignee != "" {
|
||||
suffix = fmt.Sprintf(" (assignee: %s)", assignee)
|
||||
}
|
||||
fmt.Printf(" - %s (from %s)%s\n", newTitle, issue.ID, suffix)
|
||||
}
|
||||
if len(vars) > 0 {
|
||||
fmt.Printf("\nVariables:\n")
|
||||
for k, v := range vars {
|
||||
fmt.Printf(" {{%s}} = %s\n", k, v)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Clone the subgraph (deprecated command, non-wisp for backwards compatibility)
|
||||
opts := CloneOptions{
|
||||
Vars: vars,
|
||||
Assignee: assignee,
|
||||
Actor: actor,
|
||||
Ephemeral: false,
|
||||
}
|
||||
var result *InstantiateResult
|
||||
result, err = cloneSubgraph(ctx, store, subgraph, opts)
|
||||
if err != nil {
|
||||
FatalError("instantiating template: %v", err)
|
||||
}
|
||||
|
||||
if jsonOutput {
|
||||
outputJSON(result)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("%s Created %d issues from template\n", ui.RenderPass("✓"), result.Created)
|
||||
fmt.Printf(" New epic: %s\n", result.NewEpicID)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
templateInstantiateCmd.Flags().StringArray("var", []string{}, "Variable substitution (key=value)")
|
||||
templateInstantiateCmd.Flags().Bool("dry-run", false, "Preview what would be created")
|
||||
templateInstantiateCmd.Flags().String("assignee", "", "Assign the root epic to this agent/user")
|
||||
|
||||
templateCmd.AddCommand(templateListCmd)
|
||||
templateCmd.AddCommand(templateShowCmd)
|
||||
templateCmd.AddCommand(templateInstantiateCmd)
|
||||
rootCmd.AddCommand(templateCmd)
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Beads Template Functions
|
||||
// =============================================================================
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"slices"
|
||||
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/beads/internal/ui"
|
||||
)
|
||||
|
||||
|
|
@ -108,23 +107,6 @@ var beadsContributors = map[string]int{
|
|||
"Zachary Rosen": 1,
|
||||
}
|
||||
|
||||
var thanksCmd = &cobra.Command{
|
||||
Use: "thanks",
|
||||
Short: "Thank the human contributors to beads",
|
||||
Hidden: true, // Deprecated: use 'bd info --thanks' instead
|
||||
Long: `Display a thank you page listing all human contributors to the beads project.
|
||||
|
||||
DEPRECATED: Use 'bd info --thanks' instead.
|
||||
|
||||
Examples:
|
||||
bd info --thanks # Show thank you page (preferred)
|
||||
bd thanks # Legacy command (still works)
|
||||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
printThanksPage()
|
||||
},
|
||||
}
|
||||
|
||||
// getContributorsSorted returns contributors sorted by commit count descending
|
||||
func getContributorsSorted() []string {
|
||||
type kv struct {
|
||||
|
|
@ -270,6 +252,3 @@ func printThanksWrappedList(label string, names []string, maxWidth int) {
|
|||
fmt.Println()
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(thanksCmd)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,250 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# migrate-audit.sh — Audit and batch-migrate beads boards from SQLite to Dolt
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/migrate-audit.sh # Audit only (dry run)
|
||||
# ./scripts/migrate-audit.sh --migrate # Audit + migrate all eligible boards
|
||||
# ./scripts/migrate-audit.sh --migrate --port 3307 # Migrate using specific Dolt server port
|
||||
#
|
||||
# This script:
|
||||
# 1. Finds all .beads/ directories under ~/github (configurable via BEADS_SEARCH_ROOT)
|
||||
# 2. Reports the state of each board (backend, issue count, schema version)
|
||||
# 3. Optionally migrates all eligible SQLite boards to Dolt
|
||||
#
|
||||
# Safety: always creates backups, never destroys data, reports failures clearly.
|
||||
#
|
||||
# Requires: bd, sqlite3, jq
|
||||
# Fixes GH#2016, GH#2086.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SEARCH_ROOT="${BEADS_SEARCH_ROOT:-$HOME/github}"
|
||||
MAX_DEPTH="${BEADS_SEARCH_DEPTH:-4}"
|
||||
DOLT_PORT="${BEADS_DOLT_PORT:-3307}"
|
||||
DOLT_HOST="${BEADS_DOLT_HOST:-127.0.0.1}"
|
||||
DO_MIGRATE=false
|
||||
DRY_RUN=false
|
||||
EXCLUDE_PATTERN=""
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--migrate) DO_MIGRATE=true; shift ;;
|
||||
--dry-run) DO_MIGRATE=true; DRY_RUN=true; shift ;;
|
||||
--port) DOLT_PORT="$2"; shift 2 ;;
|
||||
--host) DOLT_HOST="$2"; shift 2 ;;
|
||||
--root) SEARCH_ROOT="$2"; shift 2 ;;
|
||||
--depth) MAX_DEPTH="$2"; shift 2 ;;
|
||||
--exclude) EXCLUDE_PATTERN="$2"; shift 2 ;;
|
||||
--help|-h)
|
||||
echo "Usage: $0 [--migrate] [--dry-run] [--port PORT] [--host HOST] [--root DIR] [--depth N] [--exclude PATTERN]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --migrate Actually perform migrations (default: audit only)"
|
||||
echo " --dry-run Show what --migrate would do without making changes"
|
||||
echo " --port PORT Dolt server port (default: 3307)"
|
||||
echo " --host HOST Dolt server host (default: 127.0.0.1)"
|
||||
echo " --root DIR Search root directory (default: ~/github)"
|
||||
echo " --depth N Max directory depth to search (default: 4)"
|
||||
echo " --exclude PAT Skip projects matching pattern (e.g., 'backup|test')"
|
||||
exit 0
|
||||
;;
|
||||
*) echo "Unknown option: $1"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check dependencies
|
||||
for cmd in bd sqlite3 jq; do
|
||||
if ! command -v "$cmd" &>/dev/null; then
|
||||
echo "Error: $cmd is required but not found"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Colors (if terminal supports them)
|
||||
if [[ -t 1 ]]; then
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
else
|
||||
RED='' GREEN='' YELLOW='' BLUE='' NC=''
|
||||
fi
|
||||
|
||||
# Helper: read a JSON field from metadata.json
|
||||
read_metadata() {
|
||||
local file="$1" field="$2"
|
||||
jq -r ".${field} // empty" "$file" 2>/dev/null || echo ""
|
||||
}
|
||||
|
||||
# Helper: update metadata.json with server config for migration
|
||||
write_server_config() {
|
||||
local file="$1"
|
||||
local tmp="${file}.tmp"
|
||||
jq --argjson port "$DOLT_PORT" --arg host "$DOLT_HOST" \
|
||||
'. + {dolt_server_port: $port, dolt_server_host: $host, dolt_mode: "server"}' \
|
||||
"$file" > "$tmp" && mv "$tmp" "$file"
|
||||
}
|
||||
|
||||
echo "╔══════════════════════════════════════════════════════════════╗"
|
||||
echo "║ Beads Board Migration Audit ║"
|
||||
echo "╚══════════════════════════════════════════════════════════════╝"
|
||||
echo ""
|
||||
echo "Search root: $SEARCH_ROOT"
|
||||
echo "Max depth: $MAX_DEPTH"
|
||||
echo "Dolt server: $DOLT_HOST:$DOLT_PORT"
|
||||
if $DRY_RUN; then
|
||||
echo "Mode: DRY RUN (showing what --migrate would do)"
|
||||
elif $DO_MIGRATE; then
|
||||
echo "Mode: MIGRATE"
|
||||
else
|
||||
echo "Mode: AUDIT ONLY (use --migrate to convert, --dry-run to preview)"
|
||||
fi
|
||||
if [[ -n "$EXCLUDE_PATTERN" ]]; then
|
||||
echo "Exclude: $EXCLUDE_PATTERN"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Counters
|
||||
total=0
|
||||
sqlite_boards=0
|
||||
dolt_boards=0
|
||||
redirect_boards=0
|
||||
empty_boards=0
|
||||
migrate_success=0
|
||||
migrate_fail=0
|
||||
migrate_skip=0
|
||||
|
||||
# Find all .beads directories
|
||||
while IFS= read -r beads_dir; do
|
||||
total=$((total + 1))
|
||||
project_dir=$(dirname "$beads_dir")
|
||||
project=$(basename "$project_dir")
|
||||
|
||||
# Skip excluded projects
|
||||
if [[ -n "$EXCLUDE_PATTERN" ]] && echo "$project" | grep -qE "$EXCLUDE_PATTERN"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Skip redirects
|
||||
if [[ -f "$beads_dir/redirect" ]]; then
|
||||
target=$(cat "$beads_dir/redirect")
|
||||
printf "${BLUE}↪${NC} %-35s redirect → %s\n" "$project" "$target"
|
||||
redirect_boards=$((redirect_boards + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Skip if no metadata
|
||||
if [[ ! -f "$beads_dir/metadata.json" ]]; then
|
||||
printf "${YELLOW}?${NC} %-35s no metadata.json\n" "$project"
|
||||
empty_boards=$((empty_boards + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Read backend
|
||||
backend=$(read_metadata "$beads_dir/metadata.json" "backend")
|
||||
|
||||
# Already on Dolt
|
||||
if [[ "$backend" == "dolt" ]]; then
|
||||
issue_count="?"
|
||||
if command -v bd &>/dev/null; then
|
||||
issue_count=$(cd "$project_dir" && bd count 2>/dev/null || echo "?")
|
||||
fi
|
||||
printf "${GREEN}✓${NC} %-35s dolt (issues: %s)\n" "$project" "$issue_count"
|
||||
dolt_boards=$((dolt_boards + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# SQLite backend (empty or explicit "sqlite")
|
||||
if [[ -f "$beads_dir/beads.db" ]]; then
|
||||
# Check if beads.db is a valid SQLite database (not empty/corrupt)
|
||||
file_size=$(stat -f%z "$beads_dir/beads.db" 2>/dev/null || stat -c%s "$beads_dir/beads.db" 2>/dev/null || echo "0")
|
||||
if [[ "$file_size" == "0" ]]; then
|
||||
printf "${YELLOW}?${NC} %-35s empty beads.db (0 bytes)\n" "$project"
|
||||
empty_boards=$((empty_boards + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
issue_count=$(sqlite3 "$beads_dir/beads.db" "SELECT COUNT(*) FROM issues;" 2>/dev/null || echo "err")
|
||||
if [[ "$issue_count" == "err" ]]; then
|
||||
printf "${YELLOW}?${NC} %-35s corrupt or unreadable beads.db\n" "$project"
|
||||
empty_boards=$((empty_boards + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
has_owner=$(sqlite3 "$beads_dir/beads.db" "PRAGMA table_info(issues);" 2>/dev/null | grep -c "owner" || echo "0")
|
||||
|
||||
schema_status="current"
|
||||
if [[ "$has_owner" == "0" ]]; then
|
||||
schema_status="OLD-SCHEMA"
|
||||
fi
|
||||
|
||||
if $DO_MIGRATE; then
|
||||
if [[ "$schema_status" == "OLD-SCHEMA" ]]; then
|
||||
printf "${YELLOW}⚠${NC} %-35s sqlite (%s issues, %s) — SKIPPED\n" "$project" "$issue_count" "$schema_status"
|
||||
migrate_skip=$((migrate_skip + 1))
|
||||
else
|
||||
if $DRY_RUN; then
|
||||
printf "${BLUE}→${NC} %-35s sqlite (%s issues) — WOULD migrate to %s:%s\n" "$project" "$issue_count" "$DOLT_HOST" "$DOLT_PORT"
|
||||
migrate_success=$((migrate_success + 1))
|
||||
sqlite_boards=$((sqlite_boards + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
printf "${BLUE}→${NC} %-35s sqlite (%s issues) — migrating..." "$project" "$issue_count"
|
||||
|
||||
# Backup metadata.json before modifying
|
||||
cp "$beads_dir/metadata.json" "$beads_dir/metadata.json.pre-migrate-audit"
|
||||
|
||||
# Add server config to metadata.json
|
||||
write_server_config "$beads_dir/metadata.json"
|
||||
|
||||
# Run bd list to trigger auto-migration
|
||||
migrate_output=$(cd "$project_dir" && bd list --json 2>&1) || true
|
||||
|
||||
# Check result
|
||||
new_backend=$(read_metadata "$beads_dir/metadata.json" "backend")
|
||||
|
||||
if [[ "$new_backend" == "dolt" ]]; then
|
||||
printf " ${GREEN}✓${NC}\n"
|
||||
# Clean up metadata backup on success
|
||||
rm -f "$beads_dir/metadata.json.pre-migrate-audit"
|
||||
migrate_success=$((migrate_success + 1))
|
||||
else
|
||||
# Restore original metadata.json on failure
|
||||
mv "$beads_dir/metadata.json.pre-migrate-audit" "$beads_dir/metadata.json"
|
||||
error_reason=$(echo "$migrate_output" | grep -o "Warning:.*" | head -1)
|
||||
printf " ${RED}✗${NC} %s\n" "${error_reason:-unknown error}"
|
||||
migrate_fail=$((migrate_fail + 1))
|
||||
fi
|
||||
fi
|
||||
else
|
||||
printf "${YELLOW}○${NC} %-35s sqlite (%s issues, schema: %s)\n" "$project" "$issue_count" "$schema_status"
|
||||
fi
|
||||
sqlite_boards=$((sqlite_boards + 1))
|
||||
else
|
||||
printf "${YELLOW}?${NC} %-35s backend=%s but no beads.db\n" "$project" "${backend:-empty}"
|
||||
empty_boards=$((empty_boards + 1))
|
||||
fi
|
||||
|
||||
done < <(find "$SEARCH_ROOT" -name ".beads" -type d -maxdepth "$MAX_DEPTH" 2>/dev/null | sort)
|
||||
|
||||
echo ""
|
||||
echo "════════════════════════════════════════════════════════════════"
|
||||
echo "Summary:"
|
||||
echo " Total boards: $total"
|
||||
echo " Dolt: $dolt_boards"
|
||||
echo " SQLite: $sqlite_boards"
|
||||
echo " Redirect: $redirect_boards"
|
||||
echo " Empty/Other: $empty_boards"
|
||||
|
||||
if $DO_MIGRATE; then
|
||||
echo ""
|
||||
echo "Migration results:"
|
||||
echo " Succeeded: $migrate_success"
|
||||
echo " Failed: $migrate_fail"
|
||||
echo " Skipped: $migrate_skip"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Integration test for GH#1224 - SQLite WAL mode on WSL2 Docker bind mounts
|
||||
# This test verifies that bd properly handles database creation on problematic paths
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== Testing GH#1224 Fix: SQLite WAL on WSL2 Docker Bind Mounts ==="
|
||||
|
||||
# Check if we're in WSL2
|
||||
if ! grep -qi microsoft /proc/version; then
|
||||
echo "Not running in WSL2, skipping integration test"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create test directories in different locations
|
||||
tmpdir=$(mktemp -d)
|
||||
cleanup() {
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Test 1: Native WSL2 filesystem (should use WAL mode)
|
||||
echo ""
|
||||
echo "Test 1: Native WSL2 filesystem (/tmp)"
|
||||
native_test_dir="$tmpdir/native_test"
|
||||
mkdir -p "$native_test_dir"
|
||||
cd "$native_test_dir"
|
||||
git init > /dev/null 2>&1 || true
|
||||
bd init -q > /dev/null 2>&1 || echo "Note: bd init may fail in test env, but database setup is what matters"
|
||||
if [ -f ".beads/beads.db" ]; then
|
||||
echo "✓ Database created successfully in native filesystem"
|
||||
else
|
||||
echo "✗ Failed to create database in native filesystem"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test 2: Windows filesystem path (if /mnt/c exists) - should use DELETE mode
|
||||
if [ -d "/mnt/c" ]; then
|
||||
echo ""
|
||||
echo "Test 2: Windows filesystem (/mnt/c)"
|
||||
# Note: We can't actually create a git repo in Windows filesystem from WSL2 easily,
|
||||
# but the fix ensures WAL mode is disabled for these paths
|
||||
echo "✓ Windows path detection enabled (WAL mode disabled)"
|
||||
fi
|
||||
|
||||
# Test 3: Docker Desktop bind mount detection (if /mnt/wsl exists) - should use DELETE mode
|
||||
if [ -d "/mnt/wsl" ]; then
|
||||
echo ""
|
||||
echo "Test 3: Docker Desktop bind mount (/mnt/wsl)"
|
||||
docker_test_dir="/mnt/wsl/beads-test-integration-$$"
|
||||
if mkdir -p "$docker_test_dir" 2>/dev/null; then
|
||||
cd "$docker_test_dir"
|
||||
git init > /dev/null 2>&1 || true
|
||||
# Try to use bd on this path
|
||||
if bd version > /dev/null 2>&1; then
|
||||
echo "✓ Docker bind mount path handled correctly (WAL mode disabled)"
|
||||
else
|
||||
echo "Note: bd version check may fail in test env"
|
||||
fi
|
||||
cd /
|
||||
rm -rf "$docker_test_dir" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Integration test complete ==="
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Test script to reproduce GH#1224 - SQLite WAL mode on WSL2 bind mounts
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== Testing SQLite WAL mode on WSL2 bind mounts ==="
|
||||
|
||||
# Check if we're in WSL2
|
||||
if ! grep -qi microsoft /proc/version; then
|
||||
echo "Not running in WSL2, skipping test"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create test directory in different locations
|
||||
test_paths=(
|
||||
"/tmp/beads-test-wal" # /tmp (Linux filesystem)
|
||||
"/mnt/c/temp/beads-test-wal" # Windows filesystem (if available)
|
||||
)
|
||||
|
||||
# Add Docker Desktop bind mount if available
|
||||
if [ -d "/mnt/wsl" ]; then
|
||||
test_paths+=("/mnt/wsl/beads-test-wal") # Docker Desktop bind mount
|
||||
fi
|
||||
|
||||
for test_path in "${test_paths[@]}"; do
|
||||
echo ""
|
||||
echo "Testing WAL mode at: $test_path"
|
||||
|
||||
# Create directory
|
||||
mkdir -p "$test_path"
|
||||
|
||||
# Test with SQLite CLI
|
||||
sqlite3 "$test_path/test.db" "PRAGMA journal_mode=WAL;" 2>&1 | head -1
|
||||
|
||||
# Check if WAL was actually enabled
|
||||
journal_mode=$(sqlite3 "$test_path/test.db" "PRAGMA journal_mode;" 2>&1 | head -1)
|
||||
echo "Journal mode: $journal_mode"
|
||||
|
||||
# Clean up
|
||||
rm -rf "$test_path"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=== Test complete ==="
|
||||
Loading…
Add table
Add a link
Reference in a new issue