Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor(config): merge deprecation detection into migration (#3055)
Maximilian Roosa7273f5936d8
diff --git a/CLAUDE.md b/CLAUDE.mdindex 53960c5de..36b9b4580 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -165,7 +165,7 @@ Check `Cargo.toml` before hand-rolling a utility:All config deprecation lives in one layer: pre-deserialization TOML migration in `src/config/deprecation.rs`. `migrate_content()` rewrites deprecated patterns into canonical form before serde parses; `check_and_migrate()` reuses it, and additionally detects patterns and emits per-process-deduped warnings (the user materializes migrations via `wt config update`). **Never silently drop an old config key** — that's a silent behavior change for users; migrate it.-Every deprecation is one row in the `DEPRECATION_RULES` table; the row's `RuleMode` carries the detection function and decides when the idempotent migration applies (`Structural` rewrites on every load; `UpdateOnly` only via `wt config update`, for deprecated forms that still work at runtime; `Silent` rewrites on every load with no detection). Table order is both the warning-emission order and the migration order. Detection produces a `Vec<DeprecationKind>` (`Deprecations`): each variant carries its own display payload, so `format_deprecation_warnings()` is one match over the kinds and `is_empty` is just `Vec::is_empty()`. Adding a deprecation: (1) a detection function and an idempotent migration function; (2) a `DeprecationKind` variant plus its match arm in `format_deprecation_warnings()`; (3) a `DEPRECATION_RULES` row; (4) for a removed top-level section, add a `DeprecatedSection` to `DEPRECATED_SECTION_KEYS` (canonical key plus display form) so `warn_unknown_fields` defers to the deprecation messaging and suggests the correct config file. A silently-migrated rename (e.g. `pre-create` → `pre-start`) is a `RuleMode::Silent` row with no variant — it emits no warning by construction. Renaming a field within a section follows the same shape via a TOML-level rename function (see `migrate_negated_bool`); the struct never needs the old field since migration precedes serde.+Every deprecation is one row in the `DEPRECATION_RULES` table: a single idempotent function that rewrites the pattern AND returns the `DeprecationKind`s for what it changed — there is no separate detection function, so detection and migration share one predicate and cannot drift. Detection runs the same functions against a scratch copy of the document (progressively, so a rule sees earlier rules' rewrites); the invariant for warning rules is **a warning fires exactly when `wt config update` would change the file**, pinned by `test_warning_fires_iff_update_changes` — add new edge cases to its battery. The row variant decides when the rewrite applies: `Structural` rewrites on every load; `UpdateOnly` only via `wt config update`, for deprecated forms that still work at runtime; `Silent` rewrites on every load with no warning — its function signature has no channel for a kind, which is what scopes the invariant to the other two variants. Table order is both the warning-emission order and the migration order. Each `DeprecationKind` carries its own display payload, so `format_deprecation_warnings()` is one match over the kinds. A config that can't be rewritten safely (a malformed value, an occupied destination key) is left untouched and unwarned — serde's type or unknown-field error is the messaging; an empty deprecated section is also left alone, with no message at all (it contributes no config). Adding a deprecation: (1) one idempotent migrate-and-report function; (2) a `DeprecationKind` variant plus its match arm in `format_deprecation_warnings()`; (3) a `DEPRECATION_RULES` row; (4) for a removed top-level section, add a `DeprecatedSection` to `DEPRECATED_SECTION_KEYS` (canonical key plus display form) so `warn_unknown_fields` defers to the deprecation messaging and suggests the correct config file. A silently-migrated rename (e.g. `pre-create` → `pre-start`) is a `Silent` row with no variant. Renaming a field within a section follows the same shape via a TOML-level rename function (see `migrate_negated_bool`); the struct never needs the old field since migration precedes serde.## Adding CLI Commandsdiff --git a/src/config/deprecation.rs b/src/config/deprecation.rsindex f7199abca..63dacf874 100644--- a/src/config/deprecation.rs+++ b/src/config/deprecation.rs@@ -6,9 +6,13 @@//! - Deprecated fields (args merged into command)//! - Deprecated approved-commands in \[projects\] (moved to approvals.toml)//!-//! Each deprecated pattern is one row in [`DEPRECATION_RULES`]: a detection-//! function plus an idempotent migration function. The table order is both-//! the warning-emission order and the migration order.+//! Each deprecated pattern is one row in [`DEPRECATION_RULES`]: a single+//! idempotent function that rewrites the pattern into canonical form and+//! reports what it changed. Detection runs the same functions against a+//! scratch copy of the document, so a warning fires exactly when+//! `wt config update` would change the file — detection and migration share+//! one predicate and cannot drift. The table order is both the+//! warning-emission order and the migration order.//!//! Detection is purely in-memory — nothing writes to the filesystem from a//! config load path. `check_and_migrate` returns the structurally migrated@@ -118,31 +122,40 @@ pub const DEPRECATED_SECTION_KEYS: &[DeprecatedSection] = &[////// Returns `Cow::Borrowed` if no replacements needed, avoiding allocation.pub fn normalize_template_vars(template: &str) -> Cow<'_, str> {- // Quick check: if none of the deprecated vars appear, return borrowed+ let replacements = deprecated_vars_in_template(template);+ if replacements.is_empty() {+ return Cow::Borrowed(template);+ }++ rewrite_template_var_identifiers(template, &replacements)+ .map(Cow::Owned)+ .unwrap_or(Cow::Borrowed(template))+}++/// The deprecated `(old, new)` pairs used as variables in `template`, in+/// [`DEPRECATED_VARS`] order. Empty when none appear (or the template doesn't+/// parse). An identifier appearing only as an attribute name+/// (`{{ foo.repo_root }}`) or an assignment target doesn't count — only+/// genuine variable uses, which is exactly what the rewrite replaces.+fn deprecated_vars_in_template(template: &str) -> Vec<(&'static str, &'static str)> {+ // Quick check: if none of the deprecated vars appear, skip parsingif !DEPRECATED_VARS.iter().any(|(old, _)| template.contains(old)){- return Cow::Borrowed(template);+ return Vec::new();}let env = Environment::new();let Ok(parsed) = env.template_from_str(template) else {- return Cow::Borrowed(template);+ return Vec::new();};let used_vars = parsed.undeclared_variables(false);- let replacements: Vec<_> = DEPRECATED_VARS+ DEPRECATED_VARS.iter().copied().filter(|(old, _)| used_vars.contains(*old))- .collect();- if replacements.is_empty() {- return Cow::Borrowed(template);- }-- rewrite_template_var_identifiers(template, &replacements)- .map(Cow::Owned)- .unwrap_or(Cow::Borrowed(template))+ .collect()}fn rewrite_template_var_identifiers(@@ -319,135 +332,72 @@ fn is_template_identifier_char(ch: char) -> bool {ch == '_' || ch.is_ascii_alphanumeric()}-/// Core logic for deprecated var detection, operating on pre-extracted template strings-fn find_deprecated_vars_from_strings(- template_strings: &[String],-) -> Vec<(&'static str, &'static str)> {- let mut used_vars = HashSet::new();- let env = Environment::new();-- for template_str in template_strings {- if let Ok(template) = env.template_from_str(template_str) {- used_vars.extend(template.undeclared_variables(false));- }- }-- DEPRECATED_VARS- .iter()- .filter(|(old, _)| used_vars.contains(*old))- .copied()- .collect()-}--/// Extract all string values from an already-parsed TOML document-fn extract_template_strings_from_doc(doc: &toml_edit::DocumentMut) -> Vec<String> {- let mut strings = Vec::new();- collect_strings_from_edit_table(doc.as_table(), &mut strings);- strings-}--/// Recursively collect all string values from a toml_edit table-fn collect_strings_from_edit_table(table: &toml_edit::Table, strings: &mut Vec<String>) {- for (_, item) in table.iter() {- collect_strings_from_edit_item(item, strings);- }-}--/// Recursively collect all string values from a toml_edit item-fn collect_strings_from_edit_item(item: &toml_edit::Item, strings: &mut Vec<String>) {- match item {- toml_edit::Item::Value(v) => collect_strings_from_edit_value(v, strings),- toml_edit::Item::Table(t) => collect_strings_from_edit_table(t, strings),- toml_edit::Item::ArrayOfTables(arr) => {- for t in arr.iter() {- collect_strings_from_edit_table(t, strings);- }- }- _ => {}- }-}--/// Recursively collect all string values from a toml_edit value-fn collect_strings_from_edit_value(value: &toml_edit::Value, strings: &mut Vec<String>) {- match value {- toml_edit::Value::String(s) => strings.push(s.value().clone()),- toml_edit::Value::Array(arr) => {- for v in arr.iter() {- collect_strings_from_edit_value(v, strings);- }- }- toml_edit::Value::InlineTable(t) => {- for (_, v) in t.iter() {- collect_strings_from_edit_value(v, strings);- }- }- _ => {}- }-}--/// Rewrite deprecated template variables inside one string, returning the-/// new value when it changed.-fn rewrite_deprecated_vars(original: &str) -> Option<String> {- match normalize_template_vars(original) {- Cow::Borrowed(_) => None,- Cow::Owned(modified) => Some(modified),- }-}-/// Replace deprecated template vars in every string value of the document,-/// mutating the `toml_edit` tree in place.+/// mutating the `toml_edit` tree in place; returns one+/// [`DeprecationKind::TemplateVar`] per `(old, new)` pair replaced, in+/// [`DEPRECATED_VARS`] order.////// Operating on the parsed tree (rather than a raw `str::replace` against the/// file text) is correct when the TOML source uses escapes: the decoded value/// would not appear verbatim in the file, so a raw replace silently skipped/// the migration while detection still warned. `toml_edit` re-serializes the/// changed string with proper escaping.-fn replace_deprecated_vars_in_doc(doc: &mut toml_edit::DocumentMut) -> bool {- fn walk_table(table: &mut toml_edit::Table, changed: &mut bool) {+fn migrate_template_vars_doc(doc: &mut toml_edit::DocumentMut) -> Deprecations {+ type Replaced = HashSet<(&'static str, &'static str)>;++ fn walk_table(table: &mut toml_edit::Table, replaced: &mut Replaced) {for (_, item) in table.iter_mut() {- walk_item(item, changed);+ walk_item(item, replaced);}}- fn walk_item(item: &mut toml_edit::Item, changed: &mut bool) {+ fn walk_item(item: &mut toml_edit::Item, replaced: &mut Replaced) {match item {- toml_edit::Item::Value(v) => walk_value(v, changed),- toml_edit::Item::Table(t) => walk_table(t, changed),+ toml_edit::Item::Value(v) => walk_value(v, replaced),+ toml_edit::Item::Table(t) => walk_table(t, replaced),toml_edit::Item::ArrayOfTables(arr) => {for t in arr.iter_mut() {- walk_table(t, changed);+ walk_table(t, replaced);}}_ => {}}}- fn walk_value(value: &mut toml_edit::Value, changed: &mut bool) {+ fn walk_value(value: &mut toml_edit::Value, replaced: &mut Replaced) {match value {toml_edit::Value::String(s) => {- if let Some(new) = rewrite_deprecated_vars(s.value()) {+ let pairs = deprecated_vars_in_template(s.value());+ if pairs.is_empty() {+ return;+ }+ if let Some(new) = rewrite_template_var_identifiers(s.value(), &pairs) {let decor = s.decor().clone();let mut formatted = toml_edit::Formatted::new(new);*formatted.decor_mut() = decor;*value = toml_edit::Value::String(formatted);- *changed = true;+ replaced.extend(pairs);}}toml_edit::Value::Array(arr) => {for v in arr.iter_mut() {- walk_value(v, changed);+ walk_value(v, replaced);}}toml_edit::Value::InlineTable(t) => {for (_, v) in t.iter_mut() {- walk_value(v, changed);+ walk_value(v, replaced);}}_ => {}}}- let mut changed = false;- walk_table(doc.as_table_mut(), &mut changed);- changed+ let mut replaced = Replaced::new();+ walk_table(doc.as_table_mut(), &mut replaced);+ DEPRECATED_VARS+ .iter()+ .filter(|pair| replaced.contains(*pair))+ .map(|&(old, new)| DeprecationKind::TemplateVar { old, new })+ .collect()}/// Information about deprecated commit-generation sections found in config@@ -502,51 +452,45 @@ pub enum DeprecationKind {/// deprecated.pub type Deprecations = Vec<DeprecationKind>;-/// Detection half of a [`DeprecationRule`]: append any detected kinds to-/// `kinds`. Rules run in table order, so each pushes its kinds in-/// warning-emission order.-type DetectFn = fn(&toml_edit::DocumentMut, &mut Deprecations);--/// Migration half of a [`DeprecationRule`]: rewrite the deprecated pattern-/// into canonical form, returning whether the document changed. Idempotent —-/// feeding a migrated document back in is a no-op.-type MigrateFn = fn(&mut toml_edit::DocumentMut) -> bool;--/// How a [`DeprecationRule`] participates in detection and migration.-///-/// The shape makes invalid rules unrepresentable: a rule that migrates only-/// on `wt config update` always has a detection to gate on, and a silent rule-/// has no detection — so it emits no warning by construction.-enum RuleMode {+/// A warning rule's single function: rewrite the deprecated pattern into+/// canonical form and return one [`DeprecationKind`] per warning for what+/// changed. A non-empty return means the document was modified — the same+/// value drives the rewrite, the warning, and the `wt config update` diff,+/// so a rule cannot rewrite without warning or warn about something the+/// rewrite won't fix. Idempotent — feeding a migrated document back in+/// returns empty.+type MigrateFn = fn(&mut toml_edit::DocumentMut) -> Deprecations;++/// A silent rule's migration: rewrites with no warning by construction — the+/// signature has no channel for a [`DeprecationKind`]. Returns whether the+/// document changed.+type SilentMigrateFn = fn(&mut toml_edit::DocumentMut) -> bool;++/// One deprecated config pattern: a single function that detects, rewrites,+/// and reports, plus when the rewrite applies.+enum DeprecationRule {/// Warns, and is rewritten on every config load before serde parses.- Structural(DetectFn),+ Structural(MigrateFn),/// Warns, but the deprecated form still works at runtime (deprecated/// template variables resolve via [`normalize_template_vars`];/// `approved-commands` is still a valid serde field), so the load path/// leaves it alone. Rewritten only via [`compute_migrated_content`]- /// (`wt config show` / `wt config update`), and only when detection- /// fires — e.g. an empty `approved-commands = []` is not deprecated and- /// must survive the rewrite untouched. The gate re-runs detection on the- /// partially migrated document, so key an `UpdateOnly` detection on- /// sections no earlier rule rewrites — otherwise the rule could migrate- /// without ever having warned.- UpdateOnly(DetectFn),+ /// (`wt config show` / `wt config update`).+ UpdateOnly(MigrateFn),/// Silently-migrated rename: rewritten on every load like `Structural`,- /// but with no `DeprecationKind` and no warning by construction.- Silent,-}--/// One deprecated config pattern: how to detect it and how to rewrite it.-struct DeprecationRule {- mode: RuleMode,- migrate: MigrateFn,+ /// but with no warning by construction.+ Silent(SilentMigrateFn),}/// Every deprecation, one row each. The table order is the contract:/// detection ([`detect_deprecations_from_doc`]) and migration/// ([`migrate_content_doc`], [`compute_migrated_content`]) iterate top to/// bottom, so a row's position is both its warning-emission position and its-/// migration position.+/// migration position. Detection applies each rule to a scratch copy that+/// earlier rules have already migrated, so a rule reports a pattern in its+/// post-migration shape — e.g. a `timeout-ms` written under `[select]` is+/// reported by the timeout rule after the `[select]` rule moves it under+/// `[switch.picker]`.////// Most rows rewrite disjoint keys, but one ordering is load-bearing:/// - `[select]` → `[switch.picker]` precedes the rules that edit keys under@@ -558,108 +502,64 @@ struct DeprecationRule {/// `[ci]`'s explicit document position (see [`migrate_ci_doc`]), so its/// rendered placement doesn't depend on which tables other rules re-append.///-/// Adding a deprecation: a detection fn and an idempotent migration fn-/// (one-line `any_config_table` / `for_each_config_table_mut` compositions-/// live directly in the row), a [`DeprecationKind`] variant with its-/// `format_deprecation_warnings` arm, and a row here (plus a-/// [`DeprecatedSection`] entry for a removed top-level section). A-/// silently-migrated rename is just a [`RuleMode::Silent`] row.+/// A [`DeprecationRule::Structural`] rule must not depend on an `UpdateOnly`+/// rewrite preceding it: the load path skips `UpdateOnly` rules while+/// detection applies them, so such a dependency would make the load-path+/// rewrite diverge from what was warned. The current `UpdateOnly` rules+/// rewrite key spaces no other rule reads (template strings and+/// `approved-commands`).+///+/// Adding a deprecation: a single idempotent migrate-and-report fn, a+/// [`DeprecationKind`] variant with its `format_deprecation_warnings` arm,+/// and a row here (plus a [`DeprecatedSection`] entry for a removed top-level+/// section). A silently-migrated rename is just a [`DeprecationRule::Silent`]+/// row.const DEPRECATION_RULES: &[DeprecationRule] = &[// Template variables: {{ repo_root }} → {{ repo_path }} etc., inside any// string value.- DeprecationRule {- mode: RuleMode::UpdateOnly(|doc, kinds| {- let template_strings = extract_template_strings_from_doc(doc);- for (old, new) in find_deprecated_vars_from_strings(&template_strings) {- kinds.push(DeprecationKind::TemplateVar { old, new });- }- }),- migrate: replace_deprecated_vars_in_doc,- },+ DeprecationRule::UpdateOnly(migrate_template_vars_doc),// [commit-generation] → [commit.generation], top-level and per-project.- DeprecationRule {- mode: RuleMode::Structural(|doc, kinds| {- let commit_gen = find_commit_generation_from_doc(doc);- if !commit_gen.is_empty() {- kinds.push(DeprecationKind::CommitGeneration(commit_gen));- }- }),- migrate: |doc| {- for_each_config_table_mut(doc, |_, table| migrate_commit_generation_in(table))- },- },+ DeprecationRule::Structural(migrate_commit_generation_doc),// approved-commands under [projects."..."] → approvals.toml. The rule only// removes; `wt config update` copies the entries to approvals.toml first// (see `copy_approved_commands_to_approvals_file`).- DeprecationRule {- mode: RuleMode::UpdateOnly(|doc, kinds| {- if find_approved_commands_from_doc(doc) {- kinds.push(DeprecationKind::ApprovedCommands);- }- }),- migrate: remove_approved_commands_doc,- },+ DeprecationRule::UpdateOnly(remove_approved_commands_doc),// [select] → [switch.picker].- DeprecationRule {- mode: RuleMode::Structural(|doc, kinds| {- if any_config_table(doc, |_, table| has_select_without_picker(table)) {- kinds.push(DeprecationKind::Select);- }- }),- migrate: |doc| for_each_config_table_mut(doc, |_, table| migrate_select_table(table)),- },+ DeprecationRule::Structural(|doc| {+ if for_each_config_table_mut(doc, |_, table| migrate_select_table(table)) {+ vec![DeprecationKind::Select]+ } else {+ Vec::new()+ }+ }),// pre-create/post-create → pre-start/post-start. Silent: the creation// hook rename is paused (see #2838) — both names load via serde aliases,// but in-memory migration to canonical keeps round-trip analysis// (`unknown_tree`) coherent for the table and array-of-tables forms,- // where serde aliases on the field don't cover every shape. Must precede- // the pre-hook table-form rule — see the ordering notes above.- DeprecationRule {- mode: RuleMode::Silent,- migrate: |doc| {- let pre = rename_hook_key(doc, "pre-create", "pre-start");- let post = rename_hook_key(doc, "post-create", "post-start");- pre || post- },- },+ // where serde aliases on the field don't cover every shape.+ DeprecationRule::Silent(|doc| {+ let pre = rename_hook_key(doc, "pre-create", "pre-start");+ let post = rename_hook_key(doc, "post-create", "post-start");+ pre || post+ }),// [ci] → [forge].- DeprecationRule {- mode: RuleMode::Structural(|doc, kinds| {- if find_ci_section_from_doc(doc) {- kinds.push(DeprecationKind::CiSection);- }- }),- migrate: migrate_ci_doc,- },+ DeprecationRule::Structural(migrate_ci_doc),// merge.no-ff → merge.ff (inverted).- DeprecationRule {- mode: RuleMode::Structural(|doc, kinds| {- if find_negated_bool_from_doc(doc, "merge", "no-ff", "ff") {- kinds.push(DeprecationKind::NoFf);- }- }),- migrate: |doc| migrate_negated_bool_doc(doc, "merge", "no-ff", "ff"),- },+ DeprecationRule::Structural(|doc| {+ migrate_negated_bool_doc(doc, "merge", "no-ff", "ff", DeprecationKind::NoFf)+ }),// switch.no-cd → switch.cd (inverted).- DeprecationRule {- mode: RuleMode::Structural(|doc, kinds| {- if find_negated_bool_from_doc(doc, "switch", "no-cd", "cd") {- kinds.push(DeprecationKind::NoCd);- }- }),- migrate: |doc| migrate_negated_bool_doc(doc, "switch", "no-cd", "cd"),- },+ DeprecationRule::Structural(|doc| {+ migrate_negated_bool_doc(doc, "switch", "no-cd", "cd", DeprecationKind::NoCd)+ }),// switch.picker.timeout-ms — removed; the picker renders progressively.- DeprecationRule {- mode: RuleMode::Structural(|doc, kinds| {- if any_config_table(doc, |_, table| has_switch_picker_timeout(table)) {- kinds.push(DeprecationKind::SwitchPickerTimeout);- }- }),- migrate: |doc| {- for_each_config_table_mut(doc, |_, table| remove_switch_picker_timeout_in(table))- },- },+ DeprecationRule::Structural(|doc| {+ if for_each_config_table_mut(doc, |_, table| remove_switch_picker_timeout_in(table)) {+ vec![DeprecationKind::SwitchPickerTimeout]+ } else {+ Vec::new()+ }+ }),];/// Detect deprecations in config content. Pure function, no I/O.@@ -675,42 +575,50 @@ pub fn detect_deprecations(content: &str) -> Deprecations {/// Detect deprecations from an already-parsed document.///+/// Runs every rule against a scratch copy and reports what they changed, so+/// a warning fires exactly when `wt config update` would change the file./// Pushes kinds in [`DEPRECATION_RULES`] order — the warning-emission order —/// so iterating the returned `Vec` reproduces the warning text byte-for-byte.fn detect_deprecations_from_doc(doc: &toml_edit::DocumentMut) -> Deprecations {+ let mut scratch = doc.clone();let mut kinds = Vec::new();- for rule in DEPRECATION_RULES {- match rule.mode {- RuleMode::Structural(detect) | RuleMode::UpdateOnly(detect) => detect(doc, &mut kinds),- RuleMode::Silent => {}- }- }+ apply_rules(&mut scratch, true, &mut kinds);kinds}-/// Detect-side scope walk: apply `f` to the top-level table (scope `None`) and-/// to each `[projects."key"]` table (scope `Some(key)`), short-circuiting on the-/// first `true`. The scope key feeds callers that build display paths.-fn any_config_table(- doc: &toml_edit::DocumentMut,- mut f: impl FnMut(Option<&str>, &toml_edit::Table) -> bool,+/// Run every rule in table order against `doc`, appending each rule's warning+/// kinds to `kinds` and returning whether the document changed.+///+/// `include_update_only` is false on the load path: [`DeprecationRule::UpdateOnly`]+/// rewrites are cosmetic or still-valid serde fields, so serde doesn't need+/// them applied. Detection and [`compute_migrated_content`] pass true.+fn apply_rules(+ doc: &mut toml_edit::DocumentMut,+ include_update_only: bool,+ kinds: &mut Deprecations,) -> bool {- if f(None, doc.as_table()) {- return true;- }- if let Some(projects) = doc.get("projects").and_then(|p| p.as_table()) {- for (key, value) in projects.iter() {- if let Some(table) = value.as_table()- && f(Some(key), table)- {- return true;+ let mut modified = false;+ for rule in DEPRECATION_RULES {+ match rule {+ DeprecationRule::Structural(migrate) => {+ let new_kinds = migrate(doc);+ modified |= !new_kinds.is_empty();+ kinds.extend(new_kinds);}+ DeprecationRule::UpdateOnly(migrate) => {+ if include_update_only {+ let new_kinds = migrate(doc);+ modified |= !new_kinds.is_empty();+ kinds.extend(new_kinds);+ }+ }+ DeprecationRule::Silent(migrate) => modified |= migrate(doc),}}- false+ modified}-/// Migrate-side scope walk: apply `f` mutably to the top-level table (scope+/// Scope walk: apply `f` mutably to the top-level table (scope/// `None`) and to each `[projects."key"]` table (scope `Some(key)`), returning/// whether any scope reported a change.fn for_each_config_table_mut(@@ -728,50 +636,26 @@ fn for_each_config_table_mut(modified}-fn find_approved_commands_from_doc(doc: &toml_edit::DocumentMut) -> bool {- let Some(projects) = doc.get("projects").and_then(|p| p.as_table()) else {- return false;- };-- for (_project_key, project_value) in projects.iter() {- if let Some(project_table) = project_value.as_table()- && let Some(approved) = project_table.get("approved-commands")- && approved.as_array().is_some_and(|a| !a.is_empty())- {- return true;- }- }-- false-}--/// Whether a scope has a non-empty deprecated `commit-generation` section and-/// no canonical `[commit.generation]` to supersede it. Shared by detection and-/// migration so both agree on which scopes need migrating.-fn has_deprecated_commit_generation(table: &toml_edit::Table) -> bool {- if has_table_like_child(table.get("commit"), "generation") {- return false;- }- table.get("commit-generation").is_some_and(|section| {- section.as_table().is_some_and(|t| !t.is_empty())- || section.as_inline_table().is_some_and(|t| !t.is_empty())- })-}--fn find_commit_generation_from_doc(doc: &toml_edit::DocumentMut) -> CommitGenerationDeprecations {- let mut result = CommitGenerationDeprecations::default();- // Top-level sets a bool; each project records its key — a per-scope fork, so- // the closure branches on the scope rather than returning a uniform bool.- any_config_table(doc, |scope, table| {- if has_deprecated_commit_generation(table) {+/// Migrate `[commit-generation]` → `[commit.generation]` in every scope,+/// reporting which scopes changed via the kind's payload — the top-level flag+/// plus per-project keys, each of which emits its own warning line.+fn migrate_commit_generation_doc(doc: &mut toml_edit::DocumentMut) -> Deprecations {+ let mut found = CommitGenerationDeprecations::default();+ for_each_config_table_mut(doc, |scope, table| {+ let migrated = migrate_commit_generation_in(table);+ if migrated {match scope {- None => result.has_top_level = true,- Some(key) => result.project_keys.push(key.to_string()),+ None => found.has_top_level = true,+ Some(key) => found.project_keys.push(key.to_string()),}}- false+ migrated});- result+ if found.is_empty() {+ Vec::new()+ } else {+ vec![DeprecationKind::CommitGeneration(found)]+ }}/// Whether a TOML item is a table or inline table (can be migrated as a section).@@ -782,6 +666,13 @@ fn is_table_like(item: &toml_edit::Item) -> bool {)}+/// Whether a TOML item is a table or inline table with at least one entry.+/// Section-rename rules leave empty deprecated sections alone: they contribute+/// no config, so rewriting them isn't worth a warning.+fn is_nonempty_table_like(item: &toml_edit::Item) -> bool {+ table_like_len(item).is_some_and(|len| len > 0)+}+/// Whether a slot can host a freshly-inserted subtable: absent, or already a/// (possibly inline) table. A scalar/array occupant blocks insertion — the/// migration would remove the deprecated source but have nowhere to put@@ -836,12 +727,16 @@ fn into_table(item: toml_edit::Item) -> Option<toml_edit::Table> {/// Skips when a canonical `[commit.generation]` already exists (new format takes/// precedence). Peeks before removing so a malformed value (e.g. a bare string)/// is left in place rather than silently dropped when a sibling migration also-/// serializes the doc. Requires `commit` be absent or a table — a scalar-/// `commit = "x"` blocks insertion of `[commit.generation]`, and removing the-/// source then would silently drop the deprecated section.+/// serializes the doc; an empty section is likewise left alone — it contributes+/// no config, so rewriting it isn't worth a warning. Requires `commit` be+/// absent or a table — a scalar `commit = "x"` blocks insertion of+/// `[commit.generation]`, and removing the source then would silently drop the+/// deprecated section.fn migrate_commit_generation_in(table: &mut toml_edit::Table) -> bool {if has_table_like_child(table.get("commit"), "generation")- || !table.get("commit-generation").is_some_and(is_table_like)+ || !table+ .get("commit-generation")+ .is_some_and(is_nonempty_table_like)|| !can_host_subtable(table.get("commit")){return false;@@ -849,7 +744,7 @@ fn migrate_commit_generation_in(table: &mut toml_edit::Table) -> bool {let Some(old_section) = table.remove("commit-generation") else {return false;};- let mut generation = into_table(old_section).expect("checked is_table_like above");+ let mut generation = into_table(old_section).expect("checked is_nonempty_table_like above");// Merge args into command if present.merge_args_into_command(&mut generation);@@ -862,84 +757,68 @@ fn migrate_commit_generation_in(table: &mut toml_edit::Table) -> bool {true}-/// Remove `approved-commands` from all `\[projects."..."\]` sections.+/// Remove non-empty `approved-commands` arrays from `\[projects."..."\]`+/// sections (moved to approvals.toml).///-/// For each project section, removes the `approved-commands` key.-/// If a project section becomes empty after removal, removes the project entry.-/// If the `\[projects\]` table becomes empty, removes it.-fn remove_approved_commands_doc(doc: &mut toml_edit::DocumentMut) -> bool {+/// An empty `approved-commands = []` is not deprecated and survives untouched;+/// a non-array value is left for serde's type error rather than removed+/// without ever having been copied to approvals.toml. A project section+/// emptied by the removal is dropped, as is a `\[projects\]` table emptied by+/// dropping its projects — but a pre-existing empty `\[projects\]` stays (this+/// rule didn't change it).+fn remove_approved_commands_doc(doc: &mut toml_edit::DocumentMut) -> Deprecations {let mut modified = false;if let Some(projects) = doc.get_mut("projects").and_then(|p| p.as_table_mut()) {- // Collect project keys that should have approved-commands removed- let mut remove_from: Vec<String> = Vec::new();- let mut emptied: Vec<String> = Vec::new();-- for (project_key, project_value) in projects.iter() {- if let Some(project_table) = project_value.as_table()- && project_table.contains_key("approved-commands")- {- remove_from.push(project_key.to_string());- // Will be empty after removal if approved-commands is the only key- if project_table.len() == 1 {- emptied.push(project_key.to_string());- }- }- }+ let remove_from: Vec<String> = projects+ .iter()+ .filter(|(_, project_value)| {+ project_value.as_table().is_some_and(|t| {+ t.get("approved-commands")+ .and_then(|a| a.as_array())+ .is_some_and(|a| !a.is_empty())+ })+ })+ .map(|(key, _)| key.to_string())+ .collect();for key in &remove_from {- if let Some(project_value) = projects.get_mut(key)- && let Some(project_table) = project_value.as_table_mut()- {- project_table.remove("approved-commands");- modified = true;+ let project_table = projects+ .get_mut(key)+ .and_then(|v| v.as_table_mut())+ .expect("selected as a table above");+ project_table.remove("approved-commands");+ modified = true;+ if project_table.is_empty() {+ projects.remove(key);}}-- for key in &emptied {- projects.remove(key);- }}- // Remove empty [projects] table- if doc- .get("projects")- .and_then(|p| p.as_table())- .is_some_and(|t| t.is_empty())+ if modified+ && doc+ .get("projects")+ .and_then(|p| p.as_table())+ .is_some_and(|t| t.is_empty()){doc.remove("projects");- modified = true;- }-- modified-}--/// Check if a table has a non-empty `select` section without `switch.picker`.-fn has_select_without_picker(table: &toml_edit::Table) -> bool {- let has_new_section = has_table_like_child(table.get("switch"), "picker");-- if has_new_section {- return false;}- if let Some(section) = table.get("select") {- if let Some(t) = section.as_table() {- return !t.is_empty();- }- if let Some(t) = section.as_inline_table() {- return !t.is_empty();- }+ if modified {+ vec![DeprecationKind::ApprovedCommands]+ } else {+ Vec::new()}-- false}-/// Migrate a `select` key to `switch.picker` within a table. Returns whether a-/// migration was performed. Skips when `[switch.picker]` already exists.+/// Migrate a non-empty `select` key to `switch.picker` within a table.+/// Returns whether a migration was performed. Skips when `[switch.picker]`+/// already exists.////// Leaves a malformed `select` (e.g., a string) in place rather than removing/// it — silently dropping it would lose user config when a sibling migration-/// also rewrites the document.+/// also rewrites the document. An empty section is likewise left alone — it+/// contributes no config, so rewriting it isn't worth a warning.fn migrate_select_table(table: &mut toml_edit::Table) -> bool {let has_new_section = has_table_like_child(table.get("switch"), "picker");@@ -947,7 +826,7 @@ fn migrate_select_table(table: &mut toml_edit::Table) -> bool {return false;}- if !table.get("select").is_some_and(is_table_like) {+ if !table.get("select").is_some_and(is_nonempty_table_like) {return false;}@@ -958,7 +837,7 @@ fn migrate_select_table(table: &mut toml_edit::Table) -> bool {}let select_table =- into_table(table.remove("select").unwrap()).expect("checked is_table_like above");+ into_table(table.remove("select").unwrap()).expect("checked is_nonempty_table_like above");if let Some(switch_table) = ensure_standard_table_parent(table, "switch") {switch_table.insert("picker", toml_edit::Item::Table(select_table));@@ -967,27 +846,26 @@ fn migrate_select_table(table: &mut toml_edit::Table) -> bool {true}-fn find_ci_section_from_doc(doc: &toml_edit::DocumentMut) -> bool {- // Skip if [forge] already exists- if doc- .get("forge")- .is_some_and(|f| f.is_table() || f.is_inline_table())- {- return false;+fn table_like_len(item: &toml_edit::Item) -> Option<usize> {+ match item {+ toml_edit::Item::Table(t) => Some(t.len()),+ toml_edit::Item::Value(toml_edit::Value::InlineTable(t)) => Some(t.len()),+ _ => None,}-- // Check if [ci] exists with a non-empty platform field- doc.get("ci")- .and_then(|ci| ci.as_table())- .and_then(|t| t.get("platform"))- .is_some_and(|p| p.as_str().is_some_and(|s| !s.is_empty()))}/// Migrate `[ci]` section to `[forge]`.///-/// Moves `platform` from `[ci]` to `[forge]`, preserving the value.-/// Removes `[ci]` if `platform` was its only field.-/// Skips migration if `[forge]` already exists.+/// Moves `platform` from `[ci]` to `[forge]` when `platform` is a non-empty+/// string, preserving the value. Anything else — no `[ci]`, no `platform`, an+/// empty or non-string `platform` — is left untouched: there's nothing the+/// rewrite could meaningfully move. Removes `[ci]` if `platform` was its only+/// field.+///+/// An existing `forge` key of any shape suppresses the migration: a `[forge]`+/// table means the user already migrated, and overwriting a malformed scalar+/// `forge = "x"` would silently drop their config — serde's type error points+/// at it instead.////// `[forge]` takes over `[ci]`'s document position — a fresh table has no/// position and would render at the end of the file instead of in the user's@@ -997,24 +875,19 @@ fn find_ci_section_from_doc(doc: &toml_edit::DocumentMut) -> bool {/// when other keys keep `[ci]` alive, the decor stays there and `[forge]`/// renders directly after the remainder — it shares `[ci]`'s position, the/// position sort is stable, and `[forge]` is inserted later in visit order.-fn migrate_ci_doc(doc: &mut toml_edit::DocumentMut) -> bool {- // Skip if [forge] already exists- if doc- .get("forge")- .is_some_and(|f| f.is_table() || f.is_inline_table())- {- return false;+fn migrate_ci_doc(doc: &mut toml_edit::DocumentMut) -> Deprecations {+ if doc.get("forge").is_some() {+ return Vec::new();}let Some(ci_table) = doc.get_mut("ci").and_then(|ci| ci.as_table_mut()) else {- return false;+ return Vec::new();};- // Gate before mutating: a missing or non-string platform is left untouched.if ci_table.get("platform")- .is_none_or(|p| p.as_str().is_none())+ .is_none_or(|p| p.as_str().is_none_or(str::is_empty)){- return false;+ return Vec::new();}// Move only the migrated entry; keep any other keys so we don't silently@@ -1032,77 +905,62 @@ fn migrate_ci_doc(doc: &mut toml_edit::DocumentMut) -> bool {doc.insert("forge", toml_edit::Item::Table(forge_table));- true+ vec![DeprecationKind::CiSection]}-/// Check if a section has a deprecated negated boolean field (e.g., `no-ff` without `ff`).+/// Migrate a negated boolean field within a table (e.g., `no-ff = true` →+/// `ff = false`).///-/// Checks both the top-level section and project-level sections.-fn find_negated_bool_from_doc(- doc: &toml_edit::DocumentMut,- section: &str,- old_key: &str,- new_key: &str,-) -> bool {- any_config_table(doc, |_, scope| {- scope- .get(section)- .and_then(|s| s.as_table())- .is_some_and(|table| !table.contains_key(new_key) && table.contains_key(old_key))- })-}--/// Migrate a negated boolean field within a table (e.g., `no-ff = true` → `ff = false`).+/// When the new key is already present it takes precedence: the deprecated+/// key is removed without inverting it into a value. A non-bool old value is+/// left in place for the unknown-field warning rather than silently dropped.////// Returns true if a migration was performed.fn migrate_negated_bool(table: &mut toml_edit::Table, old_key: &str, new_key: &str) -> bool {- if table.contains_key(new_key) {- // New key takes precedence; remove the old one if present- return table.remove(old_key).is_some();- }- let Some(old_item) = table.remove(old_key) else {+ let Some(old_val) = table+ .get(old_key)+ .and_then(|v| v.as_value())+ .and_then(|v| v.as_bool())+ else {return false;};- if let Some(bool_val) = old_item.as_value().and_then(|v| v.as_bool()) {- table.insert(new_key, toml_edit::value(!bool_val));- true- } else {- // Put it back if we can't parse it- table.insert(old_key, old_item);- false+ table.remove(old_key);+ if !table.contains_key(new_key) {+ table.insert(new_key, toml_edit::value(!old_val));}+ true}-/// Migrate a negated boolean field in a section and its project-level counterparts.+/// Migrate a negated boolean field in a section and its project-level+/// counterparts, reporting `kind` when any scope changed.fn migrate_negated_bool_doc(doc: &mut toml_edit::DocumentMut,section: &str,old_key: &str,new_key: &str,-) -> bool {- for_each_config_table_mut(doc, |_, scope| {+ kind: DeprecationKind,+) -> Deprecations {+ if for_each_config_table_mut(doc, |_, scope| {scope.get_mut(section).and_then(|s| s.as_table_mut()).is_some_and(|table| migrate_negated_bool(table, old_key, new_key))- })+ }) {+ vec![kind]+ } else {+ Vec::new()+ }}-/// Apply the load-path migrations — every [`RuleMode::Structural`] and-/// [`RuleMode::Silent`] rule — to a parsed document, in table order. Returns-/// true if any modifications were made.+/// Apply the load-path migrations — every [`DeprecationRule::Structural`] and+/// [`DeprecationRule::Silent`] rule — to a parsed document, in table order.+/// Returns true if any modifications were made.///-/// [`RuleMode::UpdateOnly`] rules are excluded — template variable renaming-/// is cosmetic (would break `--var` overrides), and approved-commands is-/// still a valid serde field. They apply in [`compute_migrated_content`].+/// [`DeprecationRule::UpdateOnly`] rules are excluded — template variable+/// renaming is cosmetic (would break `--var` overrides), and approved-commands+/// is still a valid serde field. They apply in [`compute_migrated_content`].fn migrate_content_doc(doc: &mut toml_edit::DocumentMut) -> bool {- let mut modified = false;- for rule in DEPRECATION_RULES {- if matches!(rule.mode, RuleMode::Structural(_) | RuleMode::Silent) {- modified |= (rule.migrate)(doc);- }- }- modified+ apply_rules(doc, false, &mut Vec::new())}/// Rename `old_key` to `new_key` at the top level and under each `[projects."..."]`.@@ -1136,29 +994,13 @@ fn rename_hook_key(doc: &mut toml_edit::DocumentMut, old_key: &str, new_key: &stmodified}-/// Check if a table has `timeout-ms` under `[switch.picker]`.+/// Remove `timeout-ms` from `[switch.picker]` in a table (top-level or project).+/// An emptied `[switch.picker]` section is left in place — it round-trips+/// harmlessly.////// `[switch.picker]` can be written either as a section (regular table) or/// inline (`picker = { ... }`); `toml_edit` surfaces these as different node/// types, so both branches are needed.-fn has_switch_picker_timeout(table: &toml_edit::Table) -> bool {- table- .get("switch")- .and_then(|s| s.as_table())- .and_then(|t| t.get("picker"))- .and_then(|p| match p {- toml_edit::Item::Table(t) => Some(t.contains_key("timeout-ms")),- toml_edit::Item::Value(toml_edit::Value::InlineTable(it)) => {- Some(it.contains_key("timeout-ms"))- }- _ => None,- })- .unwrap_or(false)-}--/// Remove `timeout-ms` from `[switch.picker]` in a table (top-level or project).-/// An emptied `[switch.picker]` section is left in place — it round-trips-/// harmlessly.fn remove_switch_picker_timeout_in(table: &mut toml_edit::Table) -> bool {let Some(picker) = table.get_mut("switch")@@ -1482,25 +1324,7 @@ pub fn compute_migrated_content(content: &str) -> String {.parse::<toml_edit::DocumentMut>().expect("compute_migrated_content called with content that failed TOML parse; callers must funnel through check_and_migrate first");- let mut modified = false;- for rule in DEPRECATION_RULES {- let apply = match rule.mode {- RuleMode::Structural(_) | RuleMode::Silent => true,- // Gated on detection: the migration may rewrite more than what- // counts as deprecated (e.g. `remove_approved_commands_doc` also- // strips an *empty* `approved-commands = []`, which detection- // deliberately ignores).- RuleMode::UpdateOnly(detect) => {- let mut kinds = Vec::new();- detect(&doc, &mut kinds);- !kinds.is_empty()- }- };- if apply {- modified |= (rule.migrate)(&mut doc);- }- }- if modified {+ if apply_rules(&mut doc, true, &mut Vec::new()) {doc.to_string()} else {content.to_string()@@ -1881,18 +1705,11 @@ mod tests {// template-var and approved-commands helpers wrap internal functions// whose isolation or parse-failure semantics have no public seam.- fn extract_template_strings(content: &str) -> Vec<String> {- let Ok(doc) = content.parse::<toml_edit::DocumentMut>() else {- return vec![];- };- extract_template_strings_from_doc(&doc)- }-fn replace_deprecated_vars(content: &str) -> String {let Ok(mut doc) = content.parse::<toml_edit::DocumentMut>() else {return content.to_string();};- if !replace_deprecated_vars_in_doc(&mut doc) {+ if migrate_template_vars_doc(&mut doc).is_empty() {return content.to_string();}// `toml_edit` always serializes a document with a trailing newline.@@ -1907,8 +1724,13 @@ mod tests {}fn find_deprecated_vars(content: &str) -> Vec<(&'static str, &'static str)> {- let strings = extract_template_strings(content);- find_deprecated_vars_from_strings(&strings)+ detect_deprecations(content)+ .into_iter()+ .filter_map(|k| match k {+ DeprecationKind::TemplateVar { old, new } => Some((old, new)),+ _ => None,+ })+ .collect()}/// True when `deprecations` carries a kind matching `pred`. Lets the@@ -1944,10 +1766,10 @@ mod tests {let Ok(mut doc) = content.parse::<toml_edit::DocumentMut>() else {return content.to_string();};- if remove_approved_commands_doc(&mut doc) {- doc.to_string()- } else {+ if remove_approved_commands_doc(&mut doc).is_empty() {content.to_string()+ } else {+ doc.to_string()}}@@ -3074,6 +2896,99 @@ ff = false"#);}+ /// A `forge` key of any shape suppresses the `[ci]` migration — a scalar+ /// `forge = "x"` must not be overwritten by the migrated table (serde's+ /// type error points at it instead).+ #[test]+ fn test_ci_migration_suppressed_by_scalar_forge() {+ let content = r#"forge = "x"++[ci]+platform = "github"+"#;+ assert_eq!(migrate_content(content), content);+ assert!(detect_deprecations(content).is_empty());+ }++ /// The framework invariant: a warning fires exactly when `wt config+ /// update` would change the file. Degenerate configs that can't be safely+ /// rewritten produce no warning and no rewrite; deprecated configs+ /// produce both. (Silent renames change the file without warning by+ /// design and aren't part of this battery.)+ #[test]+ fn test_warning_fires_iff_update_changes() {+ let untouched = [+ // [ci] without a usable platform: empty, non-string, or absent+ "[ci]\nplatform = \"\"\n",+ "[ci]\nplatform = 42\n",+ "[ci]\nhostname = \"ghe.example\"\n",+ // forge already exists — table or malformed scalar+ "[forge]\nplatform = \"gitlab\"\n\n[ci]\nplatform = \"github\"\n",+ "forge = \"x\"\n\n[ci]\nplatform = \"github\"\n",+ // empty deprecated sections contribute no config+ "[commit-generation]\n",+ "[select]\n",+ // a scalar occupant blocks the destination+ "switch = \"x\"\n\n[select]\npreview = \"p\"\n",+ "commit = \"x\"\n\n[commit-generation]\ncommand = \"llm\"\n",+ // non-bool negated key is left for the unknown-field warning,+ // whether or not the new key is present+ "[merge]\nno-ff = \"yes\"\n",+ "[merge]\nff = true\nno-ff = \"yes\"\n",+ // empty approved-commands is not deprecated+ "[projects.\"github.com/u/r\"]\napproved-commands = []\n",+ ];+ for content in untouched {+ assert!(+ detect_deprecations(content).is_empty(),+ "no warning expected for:\n{content}"+ );+ assert_eq!(+ compute_migrated_content(content),+ content,+ "no rewrite expected for:\n{content}"+ );+ }++ let rewritten = [+ "[ci]\nplatform = \"github\"\n",+ "[merge]\nff = true\nno-ff = true\n",+ "[select]\ntimeout-ms = 500\n",+ "worktree-path = \"../{{ repo_root }}.{{ branch }}\"\n",+ "[projects.\"github.com/u/r\"]\napproved-commands = [\"npm test\"]\n",+ ];+ for content in rewritten {+ assert!(+ !detect_deprecations(content).is_empty(),+ "warning expected for:\n{content}"+ );+ let migrated = compute_migrated_content(content);+ assert_ne!(migrated, content, "rewrite expected for:\n{content}");+ // The user-visible loop closes: applying the update silences the+ // warning.+ assert!(+ detect_deprecations(&migrated).is_empty(),+ "no warning expected after update for:\n{migrated}"+ );+ }+ }++ /// A `timeout-ms` written under `[select]` is reported by the timeout+ /// rule after the `[select]` rule moves it under `[switch.picker]`.+ /// (Previously it was dropped on load with only the `[select]` warning.)+ #[test]+ fn test_select_timeout_ms_warns_both_kinds() {+ let deprecations = detect_deprecations("[select]\npager = \"delta\"\ntimeout-ms = 500\n");+ assert!(has_kind(&deprecations, |k| matches!(+ k,+ DeprecationKind::Select+ )));+ assert!(has_kind(&deprecations, |k| matches!(+ k,+ DeprecationKind::SwitchPickerTimeout+ )));+ }+#[test]fn test_migrate_invalid_toml_returns_unchanged() {// When content is not valid TOML, return it unchanged@@ -3260,6 +3175,27 @@ worktree-path = ".worktrees/{{ branch | sanitize }}"assert_eq!(result, content);}+ /// An empty `approved-commands = []` is not deprecated and must survive+ /// the rewrite untouched — including when a sibling project's non-empty+ /// array triggers the rule. (Previously the whole-document migration ran+ /// once any project fired, removing empty arrays along the way.)+ #[test]+ fn test_remove_approved_commands_keeps_empty_sibling() {+ let content = r#"+[projects."github.com/user/repo1"]+approved-commands = ["npm install"]++[projects."github.com/user/repo2"]+approved-commands = []+"#;+ let result = remove_approved_commands_from_config(content);+ insta::assert_snapshot!(result, @r#"++ [projects."github.com/user/repo2"]+ approved-commands = []+ "#);+ }+#[test]fn snapshot_remove_approved_commands() {let content = r#"worktree-path = "../{{ repo }}.{{ branch | sanitize }}"@@ -3968,13 +3904,22 @@ pager = "delta")));}+ /// With both keys present, `ff` takes precedence: the deprecated key is+ /// removed without inverting it into a value, and — since the file changes+ /// on `wt config update` — a warning fires rather than dropping the key+ /// silently.#[test]- fn test_detect_no_ff_not_flagged_when_ff_exists() {- let deprecations = detect_deprecations("[merge]\nff = true\nno-ff = true\n");- assert!(!has_kind(&deprecations, |k| matches!(+ fn test_no_ff_warned_and_removed_when_ff_exists() {+ let content = "[merge]\nff = true\nno-ff = true\n";+ let deprecations = detect_deprecations(content);+ assert!(has_kind(&deprecations, |k| matches!(k,DeprecationKind::NoFf)));+ insta::assert_snapshot!(migrate_content(content), @r#"+ [merge]+ ff = true+ "#);}#[test]@@ -4200,6 +4145,11 @@ approved-commands = ["npm test"]migrated,"migration must be idempotent");+ assert!(+ detect_deprecations(&migrated).is_empty(),+ "applying the update must silence every warning; got {:?}",+ detect_deprecations(&migrated)+ );insta::assert_snapshot!(migration_diff(content, &migrated));}}