refactor: Extract stepTypeToIssueType helper to remove duplicated switch (bd-j3dj)
Extracted duplicated switch statement for mapping step type strings to types.IssueType into a single helper function. This removes code duplication between collectStepsToSubgraph() and collectStepsRecursive(). The new stepTypeToIssueType() function: - Converts 'task', 'bug', 'feature', 'epic', 'chore' to types - Returns types.TypeTask for empty or unrecognized types - Used by both functions with children-override-to-epic logic preserved
This commit is contained in:
@@ -16,6 +16,25 @@ import (
|
|||||||
"github.com/steveyegge/beads/internal/ui"
|
"github.com/steveyegge/beads/internal/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// stepTypeToIssueType converts a formula step type string to a types.IssueType.
|
||||||
|
// Returns types.TypeTask for empty or unrecognized types.
|
||||||
|
func stepTypeToIssueType(stepType string) types.IssueType {
|
||||||
|
switch stepType {
|
||||||
|
case "task":
|
||||||
|
return types.TypeTask
|
||||||
|
case "bug":
|
||||||
|
return types.TypeBug
|
||||||
|
case "feature":
|
||||||
|
return types.TypeFeature
|
||||||
|
case "epic":
|
||||||
|
return types.TypeEpic
|
||||||
|
case "chore":
|
||||||
|
return types.TypeChore
|
||||||
|
default:
|
||||||
|
return types.TypeTask
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// cookCmd compiles a formula JSON into a proto bead.
|
// cookCmd compiles a formula JSON into a proto bead.
|
||||||
var cookCmd = &cobra.Command{
|
var cookCmd = &cobra.Command{
|
||||||
Use: "cook <formula-file>",
|
Use: "cook <formula-file>",
|
||||||
@@ -419,24 +438,8 @@ func collectStepsToSubgraph(steps []*formula.Step, parentID string, issueMap map
|
|||||||
// Generate issue ID (formula-name.step-id)
|
// Generate issue ID (formula-name.step-id)
|
||||||
issueID := fmt.Sprintf("%s.%s", parentID, step.ID)
|
issueID := fmt.Sprintf("%s.%s", parentID, step.ID)
|
||||||
|
|
||||||
// Determine issue type
|
// Determine issue type (children override to epic)
|
||||||
issueType := types.TypeTask
|
issueType := stepTypeToIssueType(step.Type)
|
||||||
if step.Type != "" {
|
|
||||||
switch step.Type {
|
|
||||||
case "task":
|
|
||||||
issueType = types.TypeTask
|
|
||||||
case "bug":
|
|
||||||
issueType = types.TypeBug
|
|
||||||
case "feature":
|
|
||||||
issueType = types.TypeFeature
|
|
||||||
case "epic":
|
|
||||||
issueType = types.TypeEpic
|
|
||||||
case "chore":
|
|
||||||
issueType = types.TypeChore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If step has children, it's an epic
|
|
||||||
if len(step.Children) > 0 {
|
if len(step.Children) > 0 {
|
||||||
issueType = types.TypeEpic
|
issueType = types.TypeEpic
|
||||||
}
|
}
|
||||||
@@ -758,24 +761,8 @@ func collectStepsRecursive(steps []*formula.Step, parentID string, idMapping map
|
|||||||
// Generate issue ID (formula-name.step-id)
|
// Generate issue ID (formula-name.step-id)
|
||||||
issueID := fmt.Sprintf("%s.%s", parentID, step.ID)
|
issueID := fmt.Sprintf("%s.%s", parentID, step.ID)
|
||||||
|
|
||||||
// Determine issue type
|
// Determine issue type (children override to epic)
|
||||||
issueType := types.TypeTask
|
issueType := stepTypeToIssueType(step.Type)
|
||||||
if step.Type != "" {
|
|
||||||
switch step.Type {
|
|
||||||
case "task":
|
|
||||||
issueType = types.TypeTask
|
|
||||||
case "bug":
|
|
||||||
issueType = types.TypeBug
|
|
||||||
case "feature":
|
|
||||||
issueType = types.TypeFeature
|
|
||||||
case "epic":
|
|
||||||
issueType = types.TypeEpic
|
|
||||||
case "chore":
|
|
||||||
issueType = types.TypeChore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If step has children, it's an epic
|
|
||||||
if len(step.Children) > 0 {
|
if len(step.Children) > 0 {
|
||||||
issueType = types.TypeEpic
|
issueType = types.TypeEpic
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user