aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/plan.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-16 00:55:01 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-16 00:55:01 +0200
commit86e55e31f6905ae997619aa095706674e2ffe623 (patch)
tree35397d5b33b453b87473fac849d2fdb21ece36fa /internal/engine/plan.go
parent9a77de31dc9759708ce9c2d14ea7c0876c214e71 (diff)
downloadkrino-86e55e31f6905ae997619aa095706674e2ffe623.tar.gz
krino-86e55e31f6905ae997619aa095706674e2ffe623.zip
explain reports captures and the chain a file would get
Diffstat (limited to 'internal/engine/plan.go')
-rw-r--r--internal/engine/plan.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/internal/engine/plan.go b/internal/engine/plan.go
index d9ffeb3..f2d6312 100644
--- a/internal/engine/plan.go
+++ b/internal/engine/plan.go
@@ -42,19 +42,26 @@ func (e *Engine) Plan(ctx context.Context, d *Dir, claims *plan.Claims) (*DirPla
inputs := make([]plan.Input, len(r.Matched))
for i, fm := range r.Matched {
- rules := make([]plan.RuleMatch, len(fm.Rules))
- for j, rm := range fm.Rules {
- rules[j] = plan.RuleMatch{
- Name: rm.Rule.Name,
- Actions: rm.Rule.Conf.Actions,
- Settings: rm.Rule.Settings,
- Captures: rm.Captures,
- Reasons: rm.Reasons,
- }
- }
- inputs[i] = plan.Input{File: fm.File, Rules: rules, NoDelete: fm.NoDelete}
+ inputs[i] = plan.Input{File: fm.File, Rules: planRules(fm.Rules), NoDelete: fm.NoDelete}
}
chains := plan.Build(d.Root, inputs, e.Now(), plan.OS{}, claims)
return &DirPlan{Dir: d, Chains: chains, Result: r, Elapsed: time.Since(started)}, nil
}
+
+// planRules converts a file's matching rules into what plan.Build takes.
+// Explain builds the chain of one file the same way (GUI design ยง1.3), so
+// both go through this.
+func planRules(matched []RuleMatch) []plan.RuleMatch {
+ rules := make([]plan.RuleMatch, len(matched))
+ for i, rm := range matched {
+ rules[i] = plan.RuleMatch{
+ Name: rm.Rule.Name,
+ Actions: rm.Rule.Conf.Actions,
+ Settings: rm.Rule.Settings,
+ Captures: rm.Captures,
+ Reasons: rm.Reasons,
+ }
+ }
+ return rules
+}