Files
beads/internal/util/strings.go
gastown/crew/george aee86dfae2 fix(types): consolidate enhancement alias and fix update command
- Add "enhancement" to util.issueTypeAliases for consistency
- Make types.IssueType.Normalize() case-insensitive and include all aliases
- Fix update.go to normalize type before validation
- Remove duplicate type validation block in update.go

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 16:02:51 -08:00

41 lines
1018 B
Go

package util
import "strings"
// issueTypeAliases maps shorthand type names to canonical types
var issueTypeAliases = map[string]string{
"mr": "merge-request",
"feat": "feature",
"mol": "molecule",
"enhancement": "feature",
}
// NormalizeIssueType expands type aliases to their canonical forms.
// For example: "mr" -> "merge-request", "feat" -> "feature", "mol" -> "molecule"
// Returns the input unchanged if it's not an alias.
func NormalizeIssueType(t string) string {
if canonical, ok := issueTypeAliases[strings.ToLower(t)]; ok {
return canonical
}
return t
}
// NormalizeLabels trims whitespace, removes empty strings, and deduplicates labels
// while preserving order.
func NormalizeLabels(ss []string) []string {
seen := make(map[string]struct{})
out := make([]string, 0, len(ss))
for _, s := range ss {
s = strings.TrimSpace(s)
if s == "" {
continue
}
if _, ok := seen[s]; ok {
continue
}
seen[s] = struct{}{}
out = append(out, s)
}
return out
}