feat(types): add "enhancement" as alias for "feature" type
Support --type enhancement as an alias for --type feature when creating issues. The normalization happens before validation to ensure consistency across all code paths. Closes gt-hzanoe Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
99d6592207
commit
9ecdc00664
@@ -40,7 +40,8 @@ func validateStatusWithCustom(value interface{}, customStatuses []string) error
|
||||
// validateIssueType validates an issue type value
|
||||
func validateIssueType(value interface{}) error {
|
||||
if issueType, ok := value.(string); ok {
|
||||
if !types.IssueType(issueType).IsValid() {
|
||||
// Normalize first to support aliases like "enhancement" -> "feature"
|
||||
if !types.IssueType(issueType).Normalize().IsValid() {
|
||||
return fmt.Errorf("invalid issue type: %s", issueType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,6 +528,17 @@ func (t IssueType) IsValidWithCustom(customTypes []string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Normalize maps issue type aliases to their canonical form.
|
||||
// For example, "enhancement" -> "feature".
|
||||
func (t IssueType) Normalize() IssueType {
|
||||
switch t {
|
||||
case "enhancement":
|
||||
return TypeFeature
|
||||
default:
|
||||
return t
|
||||
}
|
||||
}
|
||||
|
||||
// RequiredSection describes a recommended section for an issue type.
|
||||
// Used by bd lint and bd create --validate for template validation.
|
||||
type RequiredSection struct {
|
||||
|
||||
@@ -28,8 +28,10 @@ func ParsePriority(content string) int {
|
||||
|
||||
// ParseIssueType extracts and validates an issue type from content.
|
||||
// Returns the validated type or error if invalid.
|
||||
// Supports type aliases like "enhancement" -> "feature".
|
||||
func ParseIssueType(content string) (types.IssueType, error) {
|
||||
issueType := types.IssueType(strings.TrimSpace(content))
|
||||
// Normalize to support aliases like "enhancement" -> "feature"
|
||||
issueType := types.IssueType(strings.TrimSpace(content)).Normalize()
|
||||
|
||||
// Use the canonical IsValid() from types package
|
||||
if !issueType.IsValid() {
|
||||
|
||||
Reference in New Issue
Block a user