Add rename-prefix --repair flag and consolidate issue ID parsing

Enhances rename-prefix command with --repair flag to consolidate databases
with multiple prefixes. Creates shared issue ID utilities to eliminate code
duplication across import and rename operations.

Key changes:
- Add --repair flag to detect and consolidate multiple issue prefixes
- Create internal/utils/issue_id.go with ExtractIssuePrefix() and ExtractIssueNumber()
- Update all duplicate prefix extraction code to use shared utilities
- Add comprehensive tests for repair functionality

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
Ryan Newton + Claude
2025-10-27 18:31:01 +00:00
parent 969f3ac03b
commit e3df9cfa97
7 changed files with 364 additions and 21 deletions

View File

@@ -9,6 +9,7 @@ import (
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/sqlite"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/utils"
)
// Phase 1: Get or create SQLite store for import
@@ -58,7 +59,7 @@ func handlePrefixMismatch(ctx context.Context, sqliteStore *sqlite.SQLiteStorage
// Analyze prefixes in imported issues
for _, issue := range issues {
prefix := extractPrefix(issue.ID)
prefix := utils.ExtractIssuePrefix(issue.ID)
if prefix != configuredPrefix {
result.PrefixMismatch = true
result.MismatchPrefixes[prefix]++
@@ -350,14 +351,6 @@ func importComments(ctx context.Context, sqliteStore *sqlite.SQLiteStorage, issu
// Helper functions
func extractPrefix(issueID string) string {
parts := strings.SplitN(issueID, "-", 2)
if len(parts) < 2 {
return "" // No prefix found
}
return parts[0]
}
func getPrefixList(prefixes map[string]int) []string {
var result []string
keys := make([]string, 0, len(prefixes))