Fix hyphenated issue prefix detection (#199)
- update prefix/number parsing to use the last hyphen across utils and nodb paths - add regression tests covering multi-hyphen prefixes in both packages
This commit is contained in:
@@ -7,20 +7,20 @@ import (
|
||||
|
||||
// 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 {
|
||||
idx := strings.LastIndex(issueID, "-")
|
||||
if idx <= 0 {
|
||||
return ""
|
||||
}
|
||||
return parts[0]
|
||||
return issueID[:idx]
|
||||
}
|
||||
|
||||
// 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 {
|
||||
idx := strings.LastIndex(issueID, "-")
|
||||
if idx < 0 || idx == len(issueID)-1 {
|
||||
return 0
|
||||
}
|
||||
var num int
|
||||
fmt.Sscanf(parts[1], "%d", &num)
|
||||
fmt.Sscanf(issueID[idx+1:], "%d", &num)
|
||||
return num
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user