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:
26
internal/utils/issue_id.go
Normal file
26
internal/utils/issue_id.go
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user