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>
27 lines
537 B
Go
27 lines
537 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// ExtractIssuePrefix extracts the prefix from an issue ID like "bd-123" -> "bd"
|
|
func ExtractIssuePrefix(issueID string) string {
|
|
parts := strings.SplitN(issueID, "-", 2)
|
|
if len(parts) < 2 {
|
|
return ""
|
|
}
|
|
return parts[0]
|
|
}
|
|
|
|
// ExtractIssueNumber extracts the number from an issue ID like "bd-123" -> 123
|
|
func ExtractIssueNumber(issueID string) int {
|
|
parts := strings.SplitN(issueID, "-", 2)
|
|
if len(parts) < 2 {
|
|
return 0
|
|
}
|
|
var num int
|
|
fmt.Sscanf(parts[1], "%d", &num)
|
|
return num
|
|
}
|