MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / detect_recipe

Function detect_recipe

atomic-core/src/record/workflow/recipes/detector.rs:97–114  ·  view source on GitHub ↗

Pick the best recipe for `ctx`. Walks the `RULES` table top-to-bottom; the first rule whose predicate matches selects its recipe. Falls back to [`Recipe::InPlaceEdit`] when nothing matches. `log::trace!` is emitted for the match (or fallback) so production builds can introspect which rule fired without rebuilding.

(ctx: &RecipeContext<'_>)

Source from the content-addressed store, hash-verified

95/// `log::trace!` is emitted for the match (or fallback) so production
96/// builds can introspect which rule fired without rebuilding.
97pub fn detect_recipe(ctx: &RecipeContext<'_>) -> Recipe {
98 for rule in RULES {
99 if (rule.predicate)(ctx) {
100 log::trace!(
101 "recipes::detect_recipe: path={:?} matched rule={:?} → {:?}",
102 ctx.path,
103 rule.name,
104 rule.recipe
105 );
106 return rule.recipe;
107 }
108 }
109 log::trace!(
110 "recipes::detect_recipe: path={:?} no rule matched → InPlaceEdit",
111 ctx.path
112 );
113 Recipe::InPlaceEdit
114}
115
116#[cfg(test)]
117mod tests {

Calls

no outgoing calls