Expression Builder Functions This file provides a functional builder pattern for constructing GitHub Actions expression trees. Rather than using a stateful fluent builder, we use composable functions that return immutable ConditionNode interfaces. Design Principles: - Composable: Functions can be
(existingCondition string, draftCondition string)
| 40 | |
| 41 | // BuildConditionTree creates a condition tree from existing if condition and new draft condition |
| 42 | func BuildConditionTree(existingCondition string, draftCondition string) ConditionNode { |
| 43 | expressionBuilderLog.Printf("Building condition tree: existing=%q, draft=%q", existingCondition, draftCondition) |
| 44 | draftNode := &ExpressionNode{Expression: draftCondition} |
| 45 | |
| 46 | if existingCondition == "" { |
| 47 | expressionBuilderLog.Print("No existing condition, using draft only") |
| 48 | return draftNode |
| 49 | } |
| 50 | |
| 51 | expressionBuilderLog.Print("Combining existing and draft conditions with AND") |
| 52 | existingNode := &ExpressionNode{Expression: existingCondition} |
| 53 | return &AndNode{Left: existingNode, Right: draftNode} |
| 54 | } |
| 55 | |
| 56 | // BuildOr creates an OR node combining two conditions |
| 57 | func BuildOr(left ConditionNode, right ConditionNode) ConditionNode { |