Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

chore: bump minijinja from 2.24.0 to 3.0.0 (#4442)

dependabot[bot]dba1c64ae9af
diff --git a/Cargo.lock b/Cargo.lock
index 32f3acce3..16a2ed1d7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1999,12 +1999,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15"
-[[package]]
-name = "memo-map"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38d1115007560874e373613744c6fba374c17688327a71c1476d1a5954cc857b"
-
[[package]]
name = "memoffset"
version = "0.9.1"
@@ -2031,11 +2025,10 @@ dependencies = [
[[package]]
name = "minijinja"
-version = "2.24.0"
+version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86886cf6dbf4e614b19c9a1eec9775f021869d7eadde0fc73921a81b90c9b4c9"
+checksum = "13345868cfa94eadafc067112ff29271380a820d5594d9ee6ba81a8d00ea5dc2"
dependencies = [
- "memo-map",
"serde",
]
diff --git a/Cargo.toml b/Cargo.toml
index 1f05b75f1..185179baa 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -198,7 +198,7 @@ tracing-subscriber = { version = "0.3.17", default-features = false, features =
# Only enable needed features; macros and multi-template loading remain disabled.
# `unstable_machinery` supplies syntax analysis for migrations and diagnostics;
# `debug` supplies error source spans, including release builds.
-minijinja = { version = "2.24", default-features = false, features = [
+minijinja = { version = "3.0", default-features = false, features = [
"builtins",
"debug",
"serde",
diff --git a/src/config/expansion.rs b/src/config/expansion.rs
index 09b2bc658..0f24cf7d9 100644
--- a/src/config/expansion.rs
+++ b/src/config/expansion.rs
@@ -18,7 +18,7 @@ use std::hash::{Hash, Hasher};
use std::sync::Arc;
use color_print::cformat;
-use minijinja::value::{Enumerator, Object, ObjectRepr, StringInput};
+use minijinja::value::{Enumerator, Object, ObjectRepr, Serde, StringInput};
use minijinja::{Environment, ErrorKind, State, UndefinedBehavior, Value};
use regex::Regex;
use serde::{Deserialize, Serialize};
@@ -1066,7 +1066,7 @@ pub fn validate_template(
// Inject vars as empty map so {{ vars.key | default(...) }} doesn't error
context.insert(
"vars".to_string(),
- minijinja::Value::from_serialize(std::collections::BTreeMap::<String, String>::new()),
+ minijinja::Value::from(std::collections::BTreeMap::<String, String>::new()),
);
// In alias and hook scopes, inject `args` as an empty sequence so
// `{{ args }}`, `{{ args[0] | default(...) }}`, `{{ args | length }}`,
@@ -1177,7 +1177,13 @@ pub fn expand_template_with(
let mut env = template_environment(repo);
if escape_mode != ShellEscapeMode::Literal {
// Preserve trailing newlines in templates (important for multiline shell commands)
- env.set_keep_trailing_newline(true);
+ let syntax = env
+ .syntax()
+ .to_builder()
+ .keep_trailing_newline(true)
+ .build()
+ .map_err(|e| build_template_error(&e, template, name, Vec::new()))?;
+ env.set_syntax(syntax);
// Shell-escape values at output time, not before template rendering.
// This ensures filters (sanitize, sanitize_db, etc.) operate on raw values
@@ -1315,12 +1321,12 @@ pub fn vars_map_to_value(entries: &std::collections::BTreeMap<String, String>) -
let value = serde_json::from_str::<serde_json::Value>(v)
.ok()
.filter(|j| j.is_object() || j.is_array())
- .map(|j| Value::from_serialize(&j))
+ .map(|j| Value::from(Serde(j)))
.unwrap_or_else(|| Value::from(v.clone()));
(k.as_str(), value)
})
.collect();
- Value::from_serialize(&vars_map)
+ Value::from(vars_map)
}
/// A stand-in for the `vars` / `git.branch` maps that answers every key
@@ -1798,18 +1804,36 @@ mod tests {
fn test_undefined_namespace_values_do_not_name_unreached_typos() {
let test = test_repo();
let vars = HashMap::from([("branch", "main"), ("args", "[]")]);
- for template in [
- "{{ args[0] }}{{ brnch }}",
- "{{ vars.missing }}{{ brnch }}",
- "{% if optional %}{{ brnch }}{% endif %}{{ vars.missing }}",
- "{% set local = brnch %}{{ local }}",
- "{{ brnch if branch else other_missing }}",
- "{{ branch | replace(brnch, '-') }}",
- "{% if false %}{{ brnch }}{% endif %}{% set brnch = vars.missing %}{{ brnch }}",
- "{% if false %}{{ brnch }}{% endif %}{% with brnch = vars.missing %}{{ brnch }}{% endwith %}",
- "{% if false %}{{ brnch }}{% endif %}{% for brnch in [vars.missing] %}{{ brnch }}{% endfor %}",
- "{% if false %}{{ brnch }}{% endif %}{% for brnch, other in [[vars.missing, 1]] %}{{ brnch }}{% endfor %}",
- "{% if false %}{{ brnch }}{% endif %}{% set captured %}{% set brnch = vars.missing %}{{ brnch }}{% endset %}",
+ for (template, undefined) in [
+ ("{{ args[0] }}{{ brnch }}", "args[0]"),
+ ("{{ vars.missing }}{{ brnch }}", "vars.missing"),
+ (
+ "{% if optional %}{{ brnch }}{% endif %}{{ vars.missing }}",
+ "vars.missing",
+ ),
+ ("{% set local = brnch %}{{ local }}", "brnch"),
+ ("{{ brnch if branch else other_missing }}", "brnch"),
+ ("{{ branch | replace(brnch, '-') }}", "brnch"),
+ (
+ "{% if false %}{{ brnch }}{% endif %}{% set brnch = vars.missing %}{{ brnch }}",
+ "vars.missing",
+ ),
+ (
+ "{% if false %}{{ brnch }}{% endif %}{% with brnch = vars.missing %}{{ brnch }}{% endwith %}",
+ "vars.missing",
+ ),
+ (
+ "{% if false %}{{ brnch }}{% endif %}{% for brnch in [vars.missing] %}{{ brnch }}{% endfor %}",
+ "vars.missing",
+ ),
+ (
+ "{% if false %}{{ brnch }}{% endif %}{% for brnch, other in [[vars.missing, 1]] %}{{ brnch }}{% endfor %}",
+ "vars.missing",
+ ),
+ (
+ "{% if false %}{{ brnch }}{% endif %}{% set captured %}{% set brnch = vars.missing %}{{ brnch }}{% endset %}",
+ "vars.missing",
+ ),
] {
let err = expand_template(
template,
@@ -1819,9 +1843,17 @@ mod tests {
"test",
)
.unwrap_err();
- assert_eq!(
- err.message,
- "Failed to expand test: undefined value @ line 1"
+ // MiniJinja names the undefined expression only when the
+ // environment's debug flag is on, which defaults to
+ // `debug_assertions`; accept either exact form.
+ let named = format!(
+ "Failed to expand test: undefined value: `{undefined}` is undefined @ line 1"
+ );
+ let unnamed = "Failed to expand test: undefined value @ line 1";
+ assert!(
+ err.message == named || err.message == unnamed,
+ "{template}: {}",
+ err.message
);
assert_eq!(err.suggestion, None);
}
diff --git a/src/config/template_analysis.rs b/src/config/template_analysis.rs
index 6a5ef241b..17e4deadc 100644
--- a/src/config/template_analysis.rs
+++ b/src/config/template_analysis.rs
@@ -27,8 +27,7 @@ impl<'a> TemplateVars<'a> {
/// renderer rejects too, left untouched rather than guessed at.
pub(super) fn of(template: &'a str) -> Option<Self> {
// Whitespace settings shape literal output, never variable spans.
- let ast =
- parse_template(template, "<config>", Default::default(), Default::default()).ok()?;
+ let ast = parse_template(template, "<config>", Default::default()).ok()?;
let mut vars = TemplateVars {
reads: Vec::new(),
bound: HashSet::new(),
@@ -182,6 +181,11 @@ impl<'a> TemplateVars<'a> {
self.expr(item);
}
}
+ ast::Expr::Tuple(node) => {
+ for item in &node.items {
+ self.expr(item);
+ }
+ }
ast::Expr::Map(node) => {
for entry in node.keys.iter().chain(&node.values) {
self.expr(entry);