Skip to content

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

refactor: restructure commit-generation config to [commit.generation] (#809)

Maximilian Roosf8aaead5b391
diff --git a/.claude-plugin/skills/worktrunk/reference/config.md b/.claude-plugin/skills/worktrunk/reference/config.md
index a943be820..f5d3cc522 100644
--- a/.claude-plugin/skills/worktrunk/reference/config.md
+++ b/.claude-plugin/skills/worktrunk/reference/config.md
@@ -80,25 +80,9 @@ worktree-path = "../{{ branch | sanitize }}"
## LLM commit messages
-Generate commit messages automatically during merge. Requires an external CLI tool. See [LLM commits docs](https://worktrunk.dev/llm-commits/) for setup and template customization.
+Generate commit messages automatically during merge. Requires an external CLI tool.
-Using [llm](https://github.com/simonw/llm) (install: `pip install llm llm-anthropic`):
-
-```toml
-[commit-generation]
-command = "llm"
-args = ["-m", "claude-haiku-4.5"]
-```
-
-Using [aichat](https://github.com/sigoden/aichat):
-
-```toml
-[commit-generation]
-command = "aichat"
-args = ["-m", "claude:claude-haiku-4.5"]
-```
-
-See [Custom prompt templates](#custom-prompt-templates) for inline template options.
+See [LLM commits docs](https://worktrunk.dev/llm-commits/) for setup and [Custom prompt templates](#custom-prompt-templates) for template customization.
## Commands
@@ -182,7 +166,7 @@ Default template:
<!-- DEFAULT_TEMPLATE_START -->
```toml
-[commit-generation]
+[commit.generation]
template = """
Write a commit message for the staged changes below.
@@ -227,7 +211,7 @@ Default template:
<!-- DEFAULT_SQUASH_TEMPLATE_START -->
```toml
-[commit-generation]
+[commit.generation]
squash-template = """
Combine these commits into a single commit message.
@@ -352,27 +336,17 @@ For nested config sections, use double underscores to separate levels:
| Config | Environment Variable |
|--------|---------------------|
| `worktree-path` | `WORKTRUNK_WORKTREE_PATH` |
-| `commit-generation.command` | `WORKTRUNK_COMMIT_GENERATION__COMMAND` |
-| `commit-generation.args` | `WORKTRUNK_COMMIT_GENERATION__ARGS` |
+| `commit.generation.command` | `WORKTRUNK_COMMIT__GENERATION__COMMAND` |
+| `commit.stage` | `WORKTRUNK_COMMIT__STAGE` |
Note the single underscore after `WORKTRUNK` and double underscores between nested keys.
-### Array values
-
-Array config values like `args = ["-m", "claude-haiku"]` can be specified as a single string in environment variables:
-
-```bash
-export WORKTRUNK_COMMIT_GENERATION__ARGS="-m claude-haiku"
-```
-
### Example: CI/testing override
Override the LLM command in CI to use a mock:
```bash
-WORKTRUNK_COMMIT_GENERATION__COMMAND=echo \
-WORKTRUNK_COMMIT_GENERATION__ARGS="test: automated commit" \
- wt merge
+WORKTRUNK_COMMIT__GENERATION__COMMAND="echo 'test: automated commit'" wt merge
```
### Other environment variables
diff --git a/.claude-plugin/skills/worktrunk/reference/llm-commits.md b/.claude-plugin/skills/worktrunk/reference/llm-commits.md
index 278d552c7..ed93845f0 100644
--- a/.claude-plugin/skills/worktrunk/reference/llm-commits.md
+++ b/.claude-plugin/skills/worktrunk/reference/llm-commits.md
@@ -4,56 +4,38 @@ Worktrunk generates commit messages by building a templated prompt and piping it
## Setup
-### Install llm
+Any command that reads a prompt from stdin and outputs a commit message works. Add to `~/.config/worktrunk/config.toml`:
-[llm](https://llm.datasette.io/) from Simon Willison is recommended:
+### Claude Code
-```bash
-$ uv tool install -U llm
+```toml
+[commit.generation]
+command = "claude -p --model haiku"
```
-### Configure an API key
-
-For Claude (recommended):
-
-```bash
-$ llm install llm-anthropic
-$ llm keys set anthropic
-```
+See [Claude Code docs](https://docs.anthropic.com/en/docs/build-with-claude/claude-code) for installation.
-For OpenAI:
+### llm
-```bash
-$ llm keys set openai
+```toml
+[commit.generation]
+command = "llm -m claude-haiku-4.5"
```
-### Add to user config
-
-Create the config file if it doesn't exist:
+Install with `uv tool install llm llm-anthropic && llm keys set anthropic`. See [llm docs](https://llm.datasette.io/).
-```bash
-$ wt config create
-```
-
-Then add the commit generation settings to `~/.config/worktrunk/config.toml`:
+### aichat
```toml
-[commit-generation]
-command = "llm"
-args = ["-m", "claude-haiku-4.5"]
+[commit.generation]
+command = "aichat -m claude:claude-haiku-4.5"
```
-Or for OpenAI:
-
-```toml
-[commit-generation]
-command = "llm"
-args = ["-m", "gpt-5-nano"]
-```
+See [aichat docs](https://github.com/sigoden/aichat).
## How it works
-When worktrunk needs a commit message, it builds a prompt from a template and pipes it to the configured LLM command. The default templates include the git diff and style guidance.
+When worktrunk needs a commit message, it builds a prompt from a template and pipes it to the configured command via shell (`sh -c`). Environment variables can be set inline in the command string.
## Usage
@@ -111,9 +93,8 @@ All variables are available in both templates:
Override the defaults with inline templates or external files:
```toml
-[commit-generation]
-command = "llm"
-args = ["-m", "claude-haiku-4.5"]
+[commit.generation]
+command = "llm -m claude-haiku-4.5"
template = """
Write a commit message for this diff. One line, under 50 chars.
@@ -147,23 +128,6 @@ Templates use [minijinja](https://docs.rs/minijinja/latest/minijinja/syntax/inde
See `wt config create --help` for the full default templates.
-## Alternative tools
-
-Any command that reads a prompt from stdin and outputs a commit message works:
-
-```toml
-# aichat
-[commit-generation]
-command = "aichat"
-args = ["-m", "claude:claude-haiku-4.5"]
-
-# Custom script
-[commit-generation]
-command = "./scripts/generate-commit.sh"
-```
-
-See [llm documentation](https://llm.datasette.io/) and [aichat](https://github.com/sigoden/aichat).
-
## Fallback behavior
When no LLM is configured, worktrunk generates deterministic messages based on changed filenames (e.g., "Changes to auth.rs & config.rs").
diff --git a/.claude/skills/writing-user-outputs/SKILL.md b/.claude/skills/writing-user-outputs/SKILL.md
index d1ecd8b17..aa5aeec71 100644
--- a/.claude/skills/writing-user-outputs/SKILL.md
+++ b/.claude/skills/writing-user-outputs/SKILL.md
@@ -639,8 +639,9 @@ output::print(hint_message("Run 'wt list' to see worktrees"))?;
- **`cformat!` for styling** — Never manual escape codes (`\x1b[...`)
- **`cformat!` variables are safe** — Tags like `<bold>` are processed at compile
time only. Runtime variable values are NOT interpreted as markup, so user
- content (branch names, commit messages, paths) can be interpolated directly
- without escaping. Do NOT escape `<`/`>` in variables — it adds extra chars.
+ content (branch names, commit messages, paths, shell commands with `<`/`>`
+ redirects) can be interpolated directly without escaping. Do NOT escape
+ `<`/`>` in variables — it adds extra chars.
- **`output::` for printing** — Preferred for consistency; direct `println!`/`eprintln!` acceptable
- **YAGNI** — Most output needs no styling
- **Graceful degradation** — Colors auto-adjust (NO_COLOR, TTY detection)
diff --git a/dev/config.example.toml b/dev/config.example.toml
index 19f97bef3..9d8698e24 100644
--- a/dev/config.example.toml
+++ b/dev/config.example.toml
@@ -38,21 +38,9 @@
#
# ## LLM commit messages
#
-# Generate commit messages automatically during merge. Requires an external CLI tool. See LLM commits docs (https://worktrunk.dev/llm-commits/) for setup and template customization.
+# Generate commit messages automatically during merge. Requires an external CLI tool.
#
-# Using llm (https://github.com/simonw/llm) (install: `pip install llm llm-anthropic`):
-#
-# [commit-generation]
-# command = "llm"
-# args = ["-m", "claude-haiku-4.5"]
-#
-# Using aichat (https://github.com/sigoden/aichat):
-#
-# [commit-generation]
-# command = "aichat"
-# args = ["-m", "claude:claude-haiku-4.5"]
-#
-# See Custom prompt templates (#custom-prompt-templates) for inline template options.
+# See LLM commits docs (https://worktrunk.dev/llm-commits/) for setup and Custom prompt templates (#custom-prompt-templates) for template customization.
#
# ## Commands
#
@@ -125,7 +113,7 @@
# Default template:
#
# <!-- DEFAULT_TEMPLATE_START -->
-# [commit-generation]
+# [commit.generation]
# template = """
# Write a commit message for the staged changes below.
#
@@ -168,7 +156,7 @@
# Default template:
#
# <!-- DEFAULT_SQUASH_TEMPLATE_START -->
-# [commit-generation]
+# [commit.generation]
# squash-template = """
# Combine these commits into a single commit message.
#
diff --git a/docs/content/config.md b/docs/content/config.md
index c64395d75..44ea4a997 100644
--- a/docs/content/config.md
+++ b/docs/content/config.md
@@ -88,25 +88,9 @@ worktree-path = "../{{ branch | sanitize }}"
## LLM commit messages
-Generate commit messages automatically during merge. Requires an external CLI tool. See [LLM commits docs](@/llm-commits.md) for setup and template customization.
+Generate commit messages automatically during merge. Requires an external CLI tool.
-Using [llm](https://github.com/simonw/llm) (install: `pip install llm llm-anthropic`):
-
-```toml
-[commit-generation]
-command = "llm"
-args = ["-m", "claude-haiku-4.5"]
-```
-
-Using [aichat](https://github.com/sigoden/aichat):
-
-```toml
-[commit-generation]
-command = "aichat"
-args = ["-m", "claude:claude-haiku-4.5"]
-```
-
-See [Custom prompt templates](#custom-prompt-templates) for inline template options.
+See [LLM commits docs](@/llm-commits.md) for setup and [Custom prompt templates](#custom-prompt-templates) for template customization.
## Commands
@@ -190,7 +174,7 @@ Default template:
<!-- DEFAULT_TEMPLATE_START -->
```toml
-[commit-generation]
+[commit.generation]
template = """
Write a commit message for the staged changes below.
@@ -235,7 +219,7 @@ Default template:
<!-- DEFAULT_SQUASH_TEMPLATE_START -->
```toml
-[commit-generation]
+[commit.generation]
squash-template = """
Combine these commits into a single commit message.
@@ -360,27 +344,17 @@ For nested config sections, use double underscores to separate levels:
| Config | Environment Variable |
|--------|---------------------|
| `worktree-path` | `WORKTRUNK_WORKTREE_PATH` |
-| `commit-generation.command` | `WORKTRUNK_COMMIT_GENERATION__COMMAND` |
-| `commit-generation.args` | `WORKTRUNK_COMMIT_GENERATION__ARGS` |
+| `commit.generation.command` | `WORKTRUNK_COMMIT__GENERATION__COMMAND` |
+| `commit.stage` | `WORKTRUNK_COMMIT__STAGE` |
Note the single underscore after `WORKTRUNK` and double underscores between nested keys.
-### Array values
-
-Array config values like `args = ["-m", "claude-haiku"]` can be specified as a single string in environment variables:
-
-```bash
-export WORKTRUNK_COMMIT_GENERATION__ARGS="-m claude-haiku"
-```
-
### Example: CI/testing override
Override the LLM command in CI to use a mock:
```bash
-WORKTRUNK_COMMIT_GENERATION__COMMAND=echo \
-WORKTRUNK_COMMIT_GENERATION__ARGS="test: automated commit" \
- wt merge
+WORKTRUNK_COMMIT__GENERATION__COMMAND="echo 'test: automated commit'" wt merge
```
### Other environment variables
diff --git a/docs/content/llm-commits.md b/docs/content/llm-commits.md
index 3960f52e3..ba57e4bfb 100644
--- a/docs/content/llm-commits.md
+++ b/docs/content/llm-commits.md
@@ -17,56 +17,38 @@ Worktrunk generates commit messages by building a templated prompt and piping it
## Setup
-### Install llm
+Any command that reads a prompt from stdin and outputs a commit message works. Add to `~/.config/worktrunk/config.toml`:
-[llm](https://llm.datasette.io/) from Simon Willison is recommended:
+### Claude Code
-```bash
-$ uv tool install -U llm
+```toml
+[commit.generation]
+command = "claude -p --model haiku"
```
-### Configure an API key
-
-For Claude (recommended):
-
-```bash
-$ llm install llm-anthropic
-$ llm keys set anthropic
-```
+See [Claude Code docs](https://docs.anthropic.com/en/docs/build-with-claude/claude-code) for installation.
-For OpenAI:
+### llm
-```bash
-$ llm keys set openai
+```toml
+[commit.generation]
+command = "llm -m claude-haiku-4.5"
```
-### Add to user config
-
-Create the config file if it doesn't exist:
+Install with `uv tool install llm llm-anthropic && llm keys set anthropic`. See [llm docs](https://llm.datasette.io/).
-```bash
-$ wt config create
-```
-
-Then add the commit generation settings to `~/.config/worktrunk/config.toml`:
+### aichat
```toml
-[commit-generation]
-command = "llm"
-args = ["-m", "claude-haiku-4.5"]
+[commit.generation]
+command = "aichat -m claude:claude-haiku-4.5"
```
-Or for OpenAI:
-
-```toml
-[commit-generation]
-command = "llm"
-args = ["-m", "gpt-5-nano"]
-```
+See [aichat docs](https://github.com/sigoden/aichat).
## How it works
-When worktrunk needs a commit message, it builds a prompt from a template and pipes it to the configured LLM command. The default templates include the git diff and style guidance.
+When worktrunk needs a commit message, it builds a prompt from a template and pipes it to the configured command via shell (`sh -c`). Environment variables can be set inline in the command string.
## Usage
@@ -124,9 +106,8 @@ All variables are available in both templates:
Override the defaults with inline templates or external files:
```toml
-[commit-generation]
-command = "llm"
-args = ["-m", "claude-haiku-4.5"]
+[commit.generation]
+command = "llm -m claude-haiku-4.5"
template = """
Write a commit message for this diff. One line, under 50 chars.
@@ -160,23 +141,6 @@ Templates use [minijinja](https://docs.rs/minijinja/latest/minijinja/syntax/inde
See `wt config create --help` for the full default templates.
-## Alternative tools
-
-Any command that reads a prompt from stdin and outputs a commit message works:
-
-```toml
-# aichat
-[commit-generation]
-command = "aichat"
-args = ["-m", "claude:claude-haiku-4.5"]
-
-# Custom script
-[commit-generation]
-command = "./scripts/generate-commit.sh"
-```
-
-See [llm documentation](https://llm.datasette.io/) and [aichat](https://github.com/sigoden/aichat).
-
## Fallback behavior
When no LLM is configured, worktrunk generates deterministic messages based on changed filenames (e.g., "Changes to auth.rs & config.rs").
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 7410cf820..c25961e04 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -1543,25 +1543,9 @@ worktree-path = "../{{ branch | sanitize }}"
## LLM commit messages
-Generate commit messages automatically during merge. Requires an external CLI tool. See [LLM commits docs](@/llm-commits.md) for setup and template customization.
+Generate commit messages automatically during merge. Requires an external CLI tool.
-Using [llm](https://github.com/simonw/llm) (install: `pip install llm llm-anthropic`):
-
-```toml
-[commit-generation]
-command = "llm"
-args = ["-m", "claude-haiku-4.5"]
-```
-
-Using [aichat](https://github.com/sigoden/aichat):
-
-```toml
-[commit-generation]
-command = "aichat"
-args = ["-m", "claude:claude-haiku-4.5"]
-```
-
-See [Custom prompt templates](#custom-prompt-templates) for inline template options.
+See [LLM commits docs](@/llm-commits.md) for setup and [Custom prompt templates](#custom-prompt-templates) for template customization.
## Commands
@@ -1645,7 +1629,7 @@ Default template:
<!-- DEFAULT_TEMPLATE_START -->
```toml
-[commit-generation]
+[commit.generation]
template = """
Write a commit message for the staged changes below.
@@ -1690,7 +1674,7 @@ Default template:
<!-- DEFAULT_SQUASH_TEMPLATE_START -->
```toml
-[commit-generation]
+[commit.generation]
squash-template = """
Combine these commits into a single commit message.
@@ -1815,27 +1799,17 @@ For nested config sections, use double underscores to separate levels:
| Config | Environment Variable |
|--------|---------------------|
| `worktree-path` | `WORKTRUNK_WORKTREE_PATH` |
-| `commit-generation.command` | `WORKTRUNK_COMMIT_GENERATION__COMMAND` |
-| `commit-generation.args` | `WORKTRUNK_COMMIT_GENERATION__ARGS` |
+| `commit.generation.command` | `WORKTRUNK_COMMIT__GENERATION__COMMAND` |
+| `commit.stage` | `WORKTRUNK_COMMIT__STAGE` |
Note the single underscore after `WORKTRUNK` and double underscores between nested keys.
-### Array values
-
-Array config values like `args = ["-m", "claude-haiku"]` can be specified as a single string in environment variables:
-
-```console
-export WORKTRUNK_COMMIT_GENERATION__ARGS="-m claude-haiku"
-```
-
### Example: CI/testing override
Override the LLM command in CI to use a mock:
```console
-WORKTRUNK_COMMIT_GENERATION__COMMAND=echo \
-WORKTRUNK_COMMIT_GENERATION__ARGS="test: automated commit" \
- wt merge
+WORKTRUNK_COMMIT__GENERATION__COMMAND="echo 'test: automated commit'" wt merge
```
### Other environment variables
diff --git a/src/commands/config/show.rs b/src/commands/config/show.rs
index 1a158eefd..7ca94b7ab 100644
--- a/src/commands/config/show.rs
+++ b/src/commands/config/show.rs
@@ -263,15 +263,7 @@ fn render_diagnostics(out: &mut String) -> anyhow::Result<()> {
return Ok(());
}
- let command_display = format!(
- "{}{}",
- commit_config.command.as_ref().unwrap(),
- if commit_config.args.is_empty() {
- String::new()
- } else {
- format!(" {}", commit_config.args.join(" "))
- }
- );
+ let command_display = commit_config.command.as_ref().unwrap().clone();
match test_commit_generation(&commit_config) {
Ok(message) => {
@@ -320,6 +312,9 @@ fn render_user_config(out: &mut String) -> anyhow::Result<()> {
return Ok(());
}
+ // Trigger deprecation warnings (runs on raw content before parsing, so works even for invalid configs)
+ let _ = UserConfig::load();
+
// Read and display the file contents
let contents = std::fs::read_to_string(&config_path).context("Failed to read config file")?;
@@ -405,6 +400,11 @@ fn render_project_config(out: &mut String) -> anyhow::Result<()> {
return Ok(());
}
+ // Trigger deprecation warnings (runs on raw content before parsing, so works even for invalid configs)
+ if let Ok(repo) = Repository::current() {
+ let _ = repo.load_project_config();
+ }
+
// Read and display the file contents
let contents = std::fs::read_to_string(&config_path).context("Failed to read config file")?;
diff --git a/src/config/deprecation.rs b/src/config/deprecation.rs
index ed343a692..3e76ad915 100644
--- a/src/config/deprecation.rs
+++ b/src/config/deprecation.rs
@@ -1,14 +1,16 @@
-//! Deprecated template variable detection and migration
+//! Deprecation detection and migration
//!
-//! Scans config file content for deprecated template variables and generates
-//! a migration file with replacements.
+//! Scans config files for deprecated patterns and generates migration files:
+//! - Deprecated template variables (repo_root → repo_path, etc.)
+//! - Deprecated config sections ([commit-generation] → [commit.generation])
+//! - Deprecated fields (args merged into command)
//!
//! Migration files are only written once per config file. The hint system tracks
//! whether a migration file has been written:
-//! - Project config: uses `worktrunk.hints.deprecated-project-config` in git config
+//! - Project config: uses `worktrunk.hints.deprecated-config` in git config
//! - User config: checks if the `.new` file already exists (no repo context)
//!
-//! To regenerate a project config migration file, run `wt config state hints clear deprecated-project-config`.
+//! To regenerate a project config migration file, run `wt config state hints clear deprecated-config`.
//! To regenerate a user config migration file, delete the existing `.new` file.
use std::borrow::Cow;
@@ -20,7 +22,7 @@ use std::sync::{LazyLock, Mutex};
use color_print::cformat;
use minijinja::Environment;
use regex::Regex;
-use shell_escape::escape;
+use shell_escape::unix::escape;
use crate::config::WorktrunkConfig;
use crate::styling::{eprintln, hint_message, warning_message};
@@ -35,8 +37,8 @@ static WARNED_DEPRECATED_PATHS: LazyLock<Mutex<HashSet<PathBuf>>> =
static WARNED_UNKNOWN_PATHS: LazyLock<Mutex<HashSet<PathBuf>>> =
LazyLock::new(|| Mutex::new(HashSet::new()));
-/// Hint name for project config deprecation warnings
-const HINT_DEPRECATED_PROJECT_CONFIG: &str = "deprecated-project-config";
+/// Hint name for config deprecation warnings
+const HINT_DEPRECATED_CONFIG: &str = "deprecated-config";
/// Mapping from deprecated variable name to its replacement
const DEPRECATED_VARS: &[(&str, &str)] = &[
@@ -46,6 +48,10 @@ const DEPRECATED_VARS: &[(&str, &str)] = &[
("main_worktree_path", "primary_worktree_path"),
];
+/// Top-level section keys that are deprecated and handled separately.
+/// Callers should filter these out before calling `warn_unknown_fields` to avoid duplicate warnings.
+pub const DEPRECATED_SECTION_KEYS: &[&str] = &["commit-generation"];
+
/// Normalize a template string by replacing deprecated variables with their canonical names.
///
/// This allows approval matching to work regardless of whether the command was saved
@@ -146,11 +152,247 @@ pub fn replace_deprecated_vars(content: &str) -> String {
result
}
-/// Check config content for deprecated variables and optionally create migration file
+/// Information about deprecated commit-generation sections found in config
+#[derive(Default)]
+pub struct CommitGenerationDeprecations {
+ /// Has top-level [commit-generation] section
+ pub has_top_level: bool,
+ /// Project keys that have deprecated [projects."...".commit-generation]
+ pub project_keys: Vec<String>,
+}
+
+impl CommitGenerationDeprecations {
+ pub fn is_empty(&self) -> bool {
+ !self.has_top_level && self.project_keys.is_empty()
+ }
+}
+
+/// Find deprecated [commit-generation] sections in config
+///
+/// Returns information about:
+/// - Top-level [commit-generation] section
+/// - Project-level [projects."...".commit-generation] sections
+pub fn find_commit_generation_deprecations(content: &str) -> CommitGenerationDeprecations {
+ let Ok(doc) = content.parse::<toml_edit::DocumentMut>() else {
+ return CommitGenerationDeprecations::default();
+ };
+
+ let mut result = CommitGenerationDeprecations::default();
+
+ // Check if new [commit.generation] already exists as a valid table
+ // (skip deprecation warning if so)
+ let has_new_section = doc
+ .get("commit")
+ .and_then(|c| c.as_table())
+ .and_then(|t| t.get("generation"))
+ .is_some_and(|g| g.is_table() || g.is_inline_table());
+
+ // Check top-level [commit-generation] - only flag if non-empty and new section doesn't exist
+ // Handle both regular tables and inline tables
+ if !has_new_section && let Some(section) = doc.get("commit-generation") {
+ if let Some(table) = section.as_table() {
+ if !table.is_empty() {
+ result.has_top_level = true;
+ }
+ } else if let Some(inline) = section.as_inline_table()
+ && !inline.is_empty()
+ {
+ result.has_top_level = true;
+ }
+ }
+
+ // Check [projects."...".commit-generation]
+ if let Some(projects) = doc.get("projects").and_then(|p| p.as_table()) {
+ for (project_key, project_value) in projects.iter() {
+ if let Some(project_table) = project_value.as_table() {
+ // Check if this project has new section as a valid table
+ let has_new_project_section = project_table
+ .get("commit")
+ .and_then(|c| c.as_table())
+ .and_then(|t| t.get("generation"))
+ .is_some_and(|g| g.is_table() || g.is_inline_table());
+
+ // Only flag if old section exists, is non-empty, and new doesn't exist
+ // Handle both regular tables and inline tables
+ if !has_new_project_section
+ && let Some(old_section) = project_table.get("commit-generation")
+ {
+ let is_non_empty = old_section.as_table().is_some_and(|t| !t.is_empty())
+ || old_section.as_inline_table().is_some_and(|t| !t.is_empty());
+ if is_non_empty {
+ result.project_keys.push(project_key.to_string());
+ }
+ }
+ }
+ }
+ }
+
+ result
+}
+
+/// Migrate [commit-generation] sections to [commit.generation]
+///
+/// Performs the following migrations:
+/// - Renames [commit-generation] to [commit.generation]
+/// - Merges args field into command (if present)
+/// - Renames [projects."...".commit-generation] to [projects."...".commit.generation]
+pub fn migrate_commit_generation_sections(content: &str) -> String {
+ let Ok(mut doc) = content.parse::<toml_edit::DocumentMut>() else {
+ return content.to_string();
+ };
+
+ let mut modified = false;
+
+ // Check if new [commit.generation] already exists as a valid table - if so, skip migration
+ // (new format takes precedence, don't overwrite it)
+ let has_new_section = doc
+ .get("commit")
+ .and_then(|c| c.as_table())
+ .and_then(|t| t.get("generation"))
+ .is_some_and(|g| g.is_table() || g.is_inline_table());
+
+ // Migrate top-level [commit-generation] → [commit.generation]
+ // Only if new section doesn't already exist
+ // Handle both regular tables and inline tables
+ if !has_new_section && let Some(old_section) = doc.remove("commit-generation") {
+ // Convert to table - works for both regular tables and inline tables
+ let table_opt = match old_section {
+ toml_edit::Item::Table(t) => Some(t),
+ toml_edit::Item::Value(toml_edit::Value::InlineTable(it)) => Some(it.into_table()),
+ _ => None,
+ };
+
+ if let Some(mut table) = table_opt {
+ // Merge args into command if present
+ merge_args_into_command(&mut table);
+
+ // Ensure [commit] section exists
+ if !doc.contains_key("commit") {
+ doc["commit"] = toml_edit::Item::Table(toml_edit::Table::new());
+ }
+
+ // Move to [commit.generation]
+ if let Some(commit_table) = doc["commit"].as_table_mut() {
+ commit_table.insert("generation", toml_edit::Item::Table(table));
+ }
+
+ modified = true;
+ }
+ }
+
+ // Migrate [projects."...".commit-generation] → [projects."...".commit.generation]
+ if let Some(projects) = doc.get_mut("projects").and_then(|p| p.as_table_mut()) {
+ for (_project_key, project_value) in projects.iter_mut() {
+ if let Some(project_table) = project_value.as_table_mut() {
+ // Check if new section already exists as a valid table for this project
+ let has_new_project_section = project_table
+ .get("commit")
+ .and_then(|c| c.as_table())
+ .and_then(|t| t.get("generation"))
+ .is_some_and(|g| g.is_table() || g.is_inline_table());
+
+ if !has_new_project_section
+ && let Some(old_section) = project_table.remove("commit-generation")
+ {
+ // Convert to table - works for both regular tables and inline tables
+ let table_opt = match old_section {
+ toml_edit::Item::Table(t) => Some(t),
+ toml_edit::Item::Value(toml_edit::Value::InlineTable(it)) => {
+ Some(it.into_table())
+ }
+ _ => None,
+ };
+
+ if let Some(mut table) = table_opt {
+ // Merge args into command if present
+ merge_args_into_command(&mut table);
+
+ // Ensure [projects."...".commit] section exists
+ if !project_table.contains_key("commit") {
+ project_table
+ .insert("commit", toml_edit::Item::Table(toml_edit::Table::new()));
+ }
+
+ // Move to [projects."...".commit.generation]
+ if let Some(commit_table) = project_table["commit"].as_table_mut() {
+ commit_table.insert("generation", toml_edit::Item::Table(table));
+ }
+
+ modified = true;
+ }
+ }
+ }
+ }
+ }
+
+ if modified {
+ doc.to_string()
+ } else {
+ content.to_string()
+ }
+}
+
+/// Merge args array into command string
///
-/// If deprecated variables are found and `warn_and_migrate` is true:
-/// 1. Emits a warning listing the deprecated variables
-/// 2. Creates a `.new` file with replacements (only if not already written)
+/// Converts: command = "llm", args = ["-m", "haiku"]
+/// To: command = "llm -m haiku"
+///
+/// Only removes `args` if it can be successfully merged into `command`.
+/// Preserves `args` if:
+/// - `command` is missing or not a string
+/// - `args` is not an array
+fn merge_args_into_command(table: &mut toml_edit::Table) {
+ // Validate preconditions before removing args
+ let can_merge = table.get("args").is_some_and(|a| a.as_array().is_some())
+ && table
+ .get("command")
+ .and_then(|c| c.as_value())
+ .is_some_and(|v| v.as_str().is_some());
+
+ if !can_merge {
+ return;
+ }
+
+ // Now safe to remove and merge
+ let args = table.remove("args").unwrap();
+ let args_array = args.as_array().unwrap();
+ let command = table
+ .get_mut("command")
+ .and_then(|c| c.as_value_mut())
+ .unwrap();
+ let cmd_str = command.as_str().unwrap();
+
+ // Filter to string args only (non-strings are dropped)
+ let args_str: Vec<&str> = args_array.iter().filter_map(|a| a.as_str()).collect();
+ if !args_str.is_empty() {
+ // Only add space if command is non-empty
+ let new_command = if cmd_str.is_empty() {
+ shell_join(&args_str)
+ } else {
+ format!("{} {}", cmd_str, shell_join(&args_str))
+ };
+ *command = toml_edit::Value::from(new_command);
+ }
+}
+
+/// Join arguments with proper shell quoting using shell_escape
+fn shell_join(args: &[&str]) -> String {
+ args.iter()
+ .map(|arg| escape(Cow::Borrowed(*arg)).into_owned())
+ .collect::<Vec<_>>()
+ .join(" ")
+}
+
+/// Check config content for deprecated patterns and optionally create migration file
+///
+/// Detects and migrates:
+/// - Deprecated template variables (repo_root → repo_path, etc.)
+/// - Deprecated [commit-generation] sections → [commit.generation]
+/// - Deprecated args field (merged into command)
+///
+/// If deprecations are found and `warn_and_migrate` is true:
+/// 1. Emits warnings listing the deprecated patterns
+/// 2. Creates a single `.new` file with all migrations applied
///
/// Set `warn_and_migrate` to false for project config on feature worktrees - the warning
/// is only actionable from the main worktree where the migration file can be applied.
@@ -163,7 +405,7 @@ pub fn replace_deprecated_vars(content: &str) -> String {
///
/// Warnings are deduplicated per path per process.
///
-/// Returns Ok(true) if deprecated variables were found, Ok(false) otherwise.
+/// Returns Ok(true) if any deprecations were found, Ok(false) otherwise.
pub fn check_and_migrate(
path: &Path,
content: &str,
@@ -171,8 +413,14 @@ pub fn check_and_migrate(
label: &str,
repo: Option<&crate::git::Repository>,
) -> anyhow::Result<bool> {
- let deprecated = find_deprecated_vars(content);
- if deprecated.is_empty() {
+ // Detect all deprecation types
+ let deprecated_vars = find_deprecated_vars(content);
+ let commit_gen_deprecations = find_commit_generation_deprecations(content);
+
+ let has_deprecated_vars = !deprecated_vars.is_empty();
+ let has_commit_gen_deprecations = !commit_gen_deprecations.is_empty();
+
+ if !has_deprecated_vars && !has_commit_gen_deprecations {
return Ok(false);
}
@@ -201,21 +449,45 @@ pub fn check_and_migrate(
// - Always regenerate if .new file exists (user kept it, so overwrite with fresh version)
// - For project config: skip if hint shown AND .new doesn't exist (user deleted it)
// - For user config: always write (no persistent hint tracking without repo)
- let should_skip_write = !new_path.exists()
- && repo.is_some_and(|r| r.has_shown_hint(HINT_DEPRECATED_PROJECT_CONFIG));
-
- // Build inline list of deprecated variables: "repo_root → repo_path, worktree → worktree_path"
- let var_list: Vec<String> = deprecated
- .iter()
- .map(|(old, new)| cformat!("<dim>{}</> → <bold>{}</>", old, new))
- .collect();
+ let should_skip_write =
+ !new_path.exists() && repo.is_some_and(|r| r.has_shown_hint(HINT_DEPRECATED_CONFIG));
+
+ // Emit warnings for each deprecation type
+ if has_deprecated_vars {
+ let var_list: Vec<String> = deprecated_vars
+ .iter()
+ .map(|(old, new)| cformat!("<dim>{}</> → <bold>{}</>", old, new))
+ .collect();
+ eprintln!(
+ "{}",
+ warning_message(format!(
+ "{} uses deprecated template variables: {}",
+ label,
+ var_list.join(", ")
+ ))
+ );
+ }
- let warning = format!(
- "{} uses deprecated template variables: {}",
- label,
- var_list.join(", ")
- );
- eprintln!("{}", warning_message(warning));
+ if has_commit_gen_deprecations {
+ let mut parts = Vec::new();
+ if commit_gen_deprecations.has_top_level {
+ parts.push("[commit-generation] → [commit.generation]".to_string());
+ }
+ for project_key in &commit_gen_deprecations.project_keys {
+ parts.push(format!(
+ "[projects.\"{}\".commit-generation] → [projects.\"{}\".commit.generation]",
+ project_key, project_key
+ ));
+ }
+ eprintln!(
+ "{}",
+ warning_message(format!(
+ "{} uses deprecated config sections: {}",
+ label,
+ parts.join(", ")
+ ))
+ );
+ }
if should_skip_write {
// User deleted the .new file but hint is set - they don't want the migration file
@@ -224,18 +496,24 @@ pub fn check_and_migrate(
"{}",
hint_message(cformat!(
"To regenerate, rerun after <bright-black>wt config state hints clear {}</>",
- HINT_DEPRECATED_PROJECT_CONFIG
+ HINT_DEPRECATED_CONFIG
))
);
} else {
- // Write migration file
- let new_content = replace_deprecated_vars(content);
+ // Apply all migrations to generate new content
+ let mut new_content = content.to_string();
+ if has_deprecated_vars {
+ new_content = replace_deprecated_vars(&new_content);
+ }
+ if has_commit_gen_deprecations {
+ new_content = migrate_commit_generation_sections(&new_content);
+ }
match std::fs::write(&new_path, &new_content) {
Ok(()) => {
// Mark hint as shown for project config
if let Some(repo) = repo {
- let _ = repo.mark_hint_shown(HINT_DEPRECATED_PROJECT_CONFIG);
+ let _ = repo.mark_hint_shown(HINT_DEPRECATED_CONFIG);
}
// Show just the filename in the message, full paths in the command
@@ -244,18 +522,17 @@ pub fn check_and_migrate(
.map(|n| n.to_string_lossy())
.unwrap_or_default();
- // Shell-escape paths for safe copy-paste
- let new_path_str = new_path.to_string_lossy();
- let path_str = path.to_string_lossy();
- let new_path_escaped = escape(Cow::Borrowed(new_path_str.as_ref()));
- let path_escaped = escape(Cow::Borrowed(path_str.as_ref()));
+ // Use forward slashes for cross-platform compatibility (works in Git Bash on Windows)
+ // Don't shell-escape since config paths rarely have special characters
+ let new_path_str = new_path.to_string_lossy().replace('\\', "/");
+ let path_str = path.to_string_lossy().replace('\\', "/");
eprintln!(
"{}",
hint_message(cformat!(
"Wrote migrated {}; to apply: <bright-black>mv -- {} {}</>",
new_filename,
- new_path_escaped,
- path_escaped
+ new_path_str,
+ path_str
))
);
}
@@ -636,4 +913,505 @@ approved-commands = [
assert!(result.is_ok());
assert!(result.unwrap());
}
+
+ #[test]
+ fn test_check_and_migrate_deduplicates_warnings() {
+ // Test that calling twice with same path skips the second warning
+ let content = r#"post-create = "{{ repo_root }}/script.sh""#;
+ // Use a unique path that won't collide with other tests
+ let unique_path = std::path::Path::new("/nonexistent/dedup_test_12345/config.toml");
+
+ // First call should process normally
+ let result1 = check_and_migrate(unique_path, content, true, "Test config", None);
+ assert!(result1.is_ok());
+ assert!(result1.unwrap());
+
+ // Second call with same path should early-return (hits the deduplication branch)
+ let result2 = check_and_migrate(unique_path, content, true, "Test config", None);
+ assert!(result2.is_ok());
+ assert!(result2.unwrap());
+ }
+
+ // Tests for commit-generation section migration
+
+ #[test]
+ fn test_find_commit_generation_deprecations_none() {
+ let content = r#"
+[commit.generation]
+command = "llm -m haiku"
+"#;
+ let result = find_commit_generation_deprecations(content);
+ assert!(result.is_empty());
+ }
+
+ #[test]
+ fn test_find_commit_generation_deprecations_top_level() {
+ let content = r#"
+[commit-generation]
+command = "llm -m haiku"
+"#;
+ let result = find_commit_generation_deprecations(content);
+ assert!(result.has_top_level);
+ assert!(result.project_keys.is_empty());
+ }
+
+ #[test]
+ fn test_find_commit_generation_deprecations_project_level() {
+ let content = r#"
+[projects."github.com/user/repo".commit-generation]
+command = "llm -m gpt-4"
+"#;
+ let result = find_commit_generation_deprecations(content);
+ assert!(!result.has_top_level);
+ assert_eq!(result.project_keys, vec!["github.com/user/repo"]);
+ }
+
+ #[test]
+ fn test_find_commit_generation_deprecations_multiple_projects() {
+ let content = r#"
+[commit-generation]
+command = "llm -m haiku"
+
+[projects."github.com/user/repo1".commit-generation]
+command = "llm -m gpt-4"
+
+[projects."github.com/user/repo2".commit-generation]
+command = "llm -m opus"
+"#;
+ let result = find_commit_generation_deprecations(content);
+ assert!(result.has_top_level);
+ assert_eq!(result.project_keys.len(), 2);
+ assert!(
+ result
+ .project_keys
+ .contains(&"github.com/user/repo1".to_string())
+ );
+ assert!(
+ result
+ .project_keys
+ .contains(&"github.com/user/repo2".to_string())
+ );
+ }
+
+ #[test]
+ fn test_migrate_commit_generation_simple() {
+ let content = r#"
+[commit-generation]
+command = "llm -m haiku"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(result.contains("[commit.generation]"));
+ assert!(result.contains("command = \"llm -m haiku\""));
+ assert!(!result.contains("[commit-generation]"));
+ }
+
+ #[test]
+ fn test_migrate_commit_generation_with_args() {
+ let content = r#"
+[commit-generation]
+command = "llm"
+args = ["-m", "haiku"]
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(result.contains("[commit.generation]"));
+ assert!(result.contains("command = \"llm -m haiku\""));
+ assert!(!result.contains("args"));
+ }
+
+ #[test]
+ fn test_migrate_commit_generation_args_with_spaces() {
+ let content = r#"
+[commit-generation]
+command = "llm"
+args = ["-m", "claude haiku 4.5"]
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(result.contains("[commit.generation]"));
+ // Args with spaces should be quoted
+ assert!(result.contains("command = \"llm -m 'claude haiku 4.5'\""));
+ }
+
+ #[test]
+ fn test_migrate_commit_generation_project_level() {
+ let content = r#"
+[projects."github.com/user/repo".commit-generation]
+command = "llm -m gpt-4"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(result.contains("[projects.\"github.com/user/repo\".commit.generation]"));
+ assert!(result.contains("command = \"llm -m gpt-4\""));
+ assert!(!result.contains("commit-generation"));
+ }
+
+ #[test]
+ fn test_migrate_commit_generation_preserves_other_fields() {
+ let content = r#"
+[commit-generation]
+command = "llm -m haiku"
+template = "Write commit: {{ diff }}"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(result.contains("[commit.generation]"));
+ assert!(result.contains("command = \"llm -m haiku\""));
+ assert!(result.contains("template = \"Write commit: {{ diff }}\""));
+ }
+
+ #[test]
+ fn test_migrate_commit_generation_preserves_existing_commit_section() {
+ let content = r#"
+[commit]
+stage = "all"
+
+[commit-generation]
+command = "llm -m haiku"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(result.contains("[commit]"));
+ assert!(result.contains("stage = \"all\""));
+ assert!(result.contains("[commit.generation]"));
+ assert!(result.contains("command = \"llm -m haiku\""));
+ }
+
+ #[test]
+ fn test_migrate_no_changes_needed() {
+ let content = r#"
+[commit.generation]
+command = "llm -m haiku"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ // Should return unchanged content
+ assert_eq!(result, content);
+ }
+
+ #[test]
+ fn test_migrate_skips_when_new_section_exists() {
+ // When both old and new sections exist, migration should NOT overwrite
+ // the new section (new takes precedence)
+ let content = r#"
+[commit.generation]
+command = "new-command"
+
+[commit-generation]
+command = "old-command"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ // New section should be preserved, old section should be removed but not migrated
+ assert!(
+ result.contains("command = \"new-command\""),
+ "New command should be preserved"
+ );
+ // Old section is left alone (not migrated since new exists)
+ assert!(
+ result.contains("[commit-generation]"),
+ "Old section is left as-is since new already exists"
+ );
+ }
+
+ #[test]
+ fn test_find_deprecations_skips_when_new_section_exists() {
+ // When new section exists, don't flag old section as deprecated
+ let content = r#"
+[commit.generation]
+command = "new-command"
+
+[commit-generation]
+command = "old-command"
+"#;
+ let result = find_commit_generation_deprecations(content);
+ assert!(
+ !result.has_top_level,
+ "Should not flag deprecation when new section exists"
+ );
+ }
+
+ #[test]
+ fn test_find_deprecations_skips_empty_section() {
+ // Empty old section should not be flagged
+ let content = r#"
+[commit-generation]
+"#;
+ let result = find_commit_generation_deprecations(content);
+ assert!(
+ !result.has_top_level,
+ "Should not flag empty deprecated section"
+ );
+ }
+
+ #[test]
+ fn test_shell_join_simple() {
+ assert_eq!(shell_join(&["-m", "haiku"]), "-m haiku");
+ }
+
+ #[test]
+ fn test_shell_join_with_spaces() {
+ assert_eq!(shell_join(&["-m", "claude haiku"]), "-m 'claude haiku'");
+ }
+
+ #[test]
+ fn test_shell_join_with_quotes() {
+ assert_eq!(shell_join(&["echo", "it's"]), "echo 'it'\\''s'");
+ }
+
+ #[test]
+ fn test_combined_migrations_template_vars_and_section_rename() {
+ // Test that both deprecated template variables AND deprecated
+ // [commit-generation] section are migrated in a single pass
+ let content = r#"
+worktree-path = "../{{ main_worktree }}.{{ branch }}"
+
+[commit-generation]
+command = "llm"
+args = ["-m", "haiku"]
+"#;
+ // First apply template var replacements
+ let step1 = replace_deprecated_vars(content);
+ assert!(step1.contains("{{ repo }}"), "main_worktree → repo");
+
+ // Then apply section migration
+ let step2 = migrate_commit_generation_sections(&step1);
+ assert!(step2.contains("[commit.generation]"), "Section renamed");
+ assert!(
+ step2.contains("command = \"llm -m haiku\""),
+ "Args merged into command"
+ );
+ assert!(
+ !step2.contains("[commit-generation]"),
+ "Old section removed"
+ );
+ assert!(!step2.contains("args"), "Args field removed");
+ }
+
+ // Tests for inline table handling
+
+ #[test]
+ fn test_find_deprecations_inline_table_top_level() {
+ // Inline table format: commit-generation = { command = "llm" }
+ let content = r#"
+commit-generation = { command = "llm -m haiku" }
+"#;
+ let result = find_commit_generation_deprecations(content);
+ assert!(result.has_top_level, "Should detect inline table format");
+ }
+
+ #[test]
+ fn test_find_deprecations_inline_table_project_level() {
+ let content = r#"
+[projects."github.com/user/repo"]
+commit-generation = { command = "llm -m gpt-4" }
+"#;
+ let result = find_commit_generation_deprecations(content);
+ assert_eq!(
+ result.project_keys,
+ vec!["github.com/user/repo"],
+ "Should detect project-level inline table"
+ );
+ }
+
+ #[test]
+ fn test_migrate_inline_table_top_level() {
+ let content = r#"
+commit-generation = { command = "llm", args = ["-m", "haiku"] }
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(
+ result.contains("[commit.generation]") || result.contains("[commit]"),
+ "Should migrate inline table"
+ );
+ assert!(
+ result.contains("command = \"llm -m haiku\""),
+ "Should merge args into command"
+ );
+ assert!(
+ !result.contains("commit-generation"),
+ "Should remove old inline table"
+ );
+ }
+
+ #[test]
+ fn test_find_deprecations_malformed_generation_not_table() {
+ // If commit.generation is a string (malformed), should still warn about old format
+ let content = r#"
+[commit]
+generation = "not a table"
+
+[commit-generation]
+command = "llm -m haiku"
+"#;
+ let result = find_commit_generation_deprecations(content);
+ assert!(
+ result.has_top_level,
+ "Should flag deprecated section when new section is malformed"
+ );
+ }
+
+ #[test]
+ fn test_migrate_inline_table_project_level() {
+ let content = r#"
+[projects."github.com/user/repo"]
+commit-generation = { command = "llm", args = ["-m", "gpt-4"] }
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(
+ result.contains("[projects.\"github.com/user/repo\".commit.generation]")
+ || result.contains("[projects.\"github.com/user/repo\".commit]"),
+ "Should migrate project-level inline table"
+ );
+ assert!(
+ result.contains("command = \"llm -m gpt-4\""),
+ "Should merge args into command"
+ );
+ assert!(
+ !result.contains("commit-generation"),
+ "Should remove old inline table"
+ );
+ }
+
+ #[test]
+ fn test_migrate_preserves_existing_commit_stage() {
+ // When [commit] section already exists with other fields, preserve them
+ let content = r#"
+[commit]
+stage = "all"
+
+[commit-generation]
+command = "llm -m haiku"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(result.contains("stage = \"all\""), "Should preserve stage");
+ assert!(
+ result.contains("[commit.generation]"),
+ "Should add generation subsection"
+ );
+ assert!(
+ result.contains("command = \"llm -m haiku\""),
+ "Should migrate command"
+ );
+ }
+
+ #[test]
+ fn test_find_deprecations_empty_inline_table() {
+ // Empty inline table should not be flagged
+ let content = r#"
+commit-generation = {}
+"#;
+ let result = find_commit_generation_deprecations(content);
+ assert!(
+ !result.has_top_level,
+ "Should not flag empty inline table as deprecated"
+ );
+ }
+
+ #[test]
+ fn test_migrate_args_without_command_preserved() {
+ // When args exists but command doesn't, args should be preserved
+ // (merge_args_into_command won't run without a command)
+ let content = r#"
+[commit-generation]
+args = ["-m", "haiku"]
+template = "some template"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(
+ result.contains("[commit.generation]"),
+ "Section should be renamed"
+ );
+ // Args should be preserved since there's no command to merge into
+ assert!(
+ result.contains("args ="),
+ "Args should be preserved when no command exists"
+ );
+ }
+
+ #[test]
+ fn test_migrate_args_with_non_string_command() {
+ // When command is not a string (e.g., integer), args should be preserved
+ let content = r#"
+[commit-generation]
+command = 123
+args = ["-m", "haiku"]
+"#;
+ let result = migrate_commit_generation_sections(content);
+ // Args should be preserved since command is not a string
+ assert!(
+ result.contains("args ="),
+ "Args should be preserved when command is not a string"
+ );
+ }
+
+ #[test]
+ fn test_migrate_command_only_no_args() {
+ // When only command exists (no args), it should migrate cleanly
+ let content = r#"
+[commit-generation]
+command = "llm -m haiku"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(result.contains("[commit.generation]"));
+ assert!(result.contains("command = \"llm -m haiku\""));
+ assert!(!result.contains("args"));
+ }
+
+ #[test]
+ fn test_migrate_empty_command_with_args() {
+ // When command is empty string but args exist, args become the command
+ let content = r#"
+[commit-generation]
+command = ""
+args = ["-m", "haiku"]
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(
+ result.contains("[commit.generation]"),
+ "Section should be renamed"
+ );
+ // Empty command + args should produce just args as command
+ assert!(
+ result.contains("command = \"-m haiku\""),
+ "Empty command should be replaced with args"
+ );
+ assert!(
+ !result.contains("args"),
+ "Args field should be removed after merge"
+ );
+ }
+
+ #[test]
+ fn test_migrate_malformed_string_value_unchanged() {
+ // When commit-generation is a string (malformed), migration skips it
+ // This exercises the `_ => None` branch in the match
+ let content = r#"
+commit-generation = "not a table"
+other = "value"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ // Malformed value is removed (doc.remove happens), but no migration occurs
+ // The content stays mostly unchanged since we don't add [commit.generation]
+ assert!(
+ !result.contains("[commit.generation]"),
+ "Should not create new section for malformed input"
+ );
+ }
+
+ #[test]
+ fn test_migrate_malformed_project_level_string_unchanged() {
+ // When project-level commit-generation is a string, migration skips it
+ let content = r#"
+[projects."github.com/user/repo"]
+commit-generation = "not a table"
+other = "value"
+"#;
+ let result = migrate_commit_generation_sections(content);
+ assert!(
+ !result.contains("[projects.\"github.com/user/repo\".commit.generation]"),
+ "Should not create new section for malformed project-level input"
+ );
+ }
+
+ #[test]
+ fn test_migrate_invalid_toml_returns_unchanged() {
+ // When content is not valid TOML, return it unchanged
+ let content = "this is [not valid {toml";
+ let result = migrate_commit_generation_sections(content);
+ assert_eq!(result, content, "Invalid TOML should be returned unchanged");
+ }
}
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 5097c09f6..e04c776a3 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -80,7 +80,7 @@ impl WorktrunkConfig for ProjectConfig {
pub use commands::{Command, CommandConfig};
pub use deprecation::check_and_migrate as check_deprecated_vars;
pub use deprecation::normalize_template_vars;
-pub use deprecation::{key_belongs_in, warn_unknown_fields};
+pub use deprecation::{DEPRECATED_SECTION_KEYS, key_belongs_in, warn_unknown_fields};
pub use expansion::{
DEPRECATED_TEMPLATE_VARS, TEMPLATE_VARS, expand_template, redact_credentials,
sanitize_branch_name, sanitize_db, short_hash,
@@ -130,7 +130,9 @@ mod tests {
let toml = toml::to_string(&config).unwrap();
// worktree-path is not serialized when None (uses built-in default)
assert!(!toml.contains("worktree-path"));
- assert!(toml.contains("commit-generation"));
+ // commit and commit-generation sections are not serialized when None
+ assert!(!toml.contains("[commit]"));
+ assert!(!toml.contains("[commit-generation]"));
}
#[test]
@@ -153,7 +155,8 @@ mod tests {
config.worktree_path(),
"../{{ repo }}.{{ branch | sanitize }}"
);
- assert_eq!(config.commit_generation.command, None);
+ // commit_generation is None by default
+ assert!(config.commit_generation.is_none());
assert!(config.projects.is_empty());
}
@@ -723,7 +726,7 @@ task2 = "echo 'Task 2 running' > task2.txt"
let toml_content = r#"
worktree-path = "../{{ main_worktree }}.{{ branch }}"
-[commit-generation]
+[commit.generation]
command = "llm"
template = "inline template"
template-file = "~/file.txt"
@@ -735,9 +738,11 @@ template-file = "~/file.txt"
// The deserialization should succeed, but validation in load() would fail
// Since we can't easily test load() without env vars, we verify the fields deserialize
if let Ok(config) = config_result {
+ let generation = config.commit.as_ref().and_then(|c| c.generation.as_ref());
// Verify validation logic: both fields should not be Some
- let has_both = config.commit_generation.template.is_some()
- && config.commit_generation.template_file.is_some();
+ let has_both = generation
+ .map(|g| g.template.is_some() && g.template_file.is_some())
+ .unwrap_or(false);
assert!(
has_both,
"Config should have both template fields set for this test"
@@ -751,7 +756,7 @@ template-file = "~/file.txt"
let toml_content = r#"
worktree-path = "../{{ main_worktree }}.{{ branch }}"
-[commit-generation]
+[commit.generation]
command = "llm"
squash-template = "inline template"
squash-template-file = "~/file.txt"
@@ -763,9 +768,11 @@ squash-template-file = "~/file.txt"
// The deserialization should succeed, but validation in load() would fail
// Since we can't easily test load() without env vars, we verify the fields deserialize
if let Ok(config) = config_result {
+ let generation = config.commit.as_ref().and_then(|c| c.generation.as_ref());
// Verify validation logic: both fields should not be Some
- let has_both = config.commit_generation.squash_template.is_some()
- && config.commit_generation.squash_template_file.is_some();
+ let has_both = generation
+ .map(|g| g.squash_template.is_some() && g.squash_template_file.is_some())
+ .unwrap_or(false);
assert!(
has_both,
"Config should have both squash template fields set for this test"
@@ -776,8 +783,7 @@ squash-template-file = "~/file.txt"
#[test]
fn test_commit_generation_config_serialization() {
let config = CommitGenerationConfig {
- command: Some("llm".to_string()),
- args: vec!["-m".to_string(), "model".to_string()],
+ command: Some("llm -m model".to_string()),
template: Some("template content".to_string()),
template_file: None,
squash_template: None,
@@ -785,7 +791,7 @@ squash-template-file = "~/file.txt"
};
let toml = toml::to_string(&config).unwrap();
- assert!(toml.contains("llm"));
+ assert!(toml.contains("llm -m model"));
assert!(toml.contains("template"));
}
diff --git a/src/config/project.rs b/src/config/project.rs
index 80ccfaf15..85fb08038 100644
--- a/src/config/project.rs
+++ b/src/config/project.rs
@@ -151,7 +151,10 @@ impl ProjectConfig {
// Warn about unknown fields (only in main worktree where it's actionable)
if is_main_worktree {
- let unknown_keys = find_unknown_keys(&contents);
+ let unknown_keys: std::collections::HashMap<_, _> = find_unknown_keys(&contents)
+ .into_iter()
+ .filter(|(k, _)| !super::deprecation::DEPRECATED_SECTION_KEYS.contains(&k.as_str()))
+ .collect();
super::deprecation::warn_unknown_fields::<ProjectConfig>(
&config_path,
&unknown_keys,
diff --git a/src/config/user.rs b/src/config/user.rs
index 53a7c6320..6a6baac9d 100644
--- a/src/config/user.rs
+++ b/src/config/user.rs
@@ -7,8 +7,7 @@ use std::sync::OnceLock;
use config::{Case, Config, ConfigError, File};
use fs2::FileExt;
-use serde::de;
-use serde::{Deserialize, Deserializer, Serialize};
+use serde::{Deserialize, Serialize};
use super::HooksConfig;
@@ -63,43 +62,6 @@ fn acquire_config_lock(config_path: &std::path::Path) -> Result<std::fs::File, C
Ok(file)
}
-/// Deserialize a Vec<String> that can also accept a single String
-/// This enables setting array config fields via environment variables
-fn deserialize_string_or_vec<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>
-where
- D: Deserializer<'de>,
-{
- struct StringOrVec;
-
- impl<'de> de::Visitor<'de> for StringOrVec {
- type Value = Vec<String>;
-
- fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
- formatter.write_str("string or array of strings")
- }
-
- fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
- where
- E: de::Error,
- {
- Ok(vec![value.to_string()])
- }
-
- fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
- where
- A: de::SeqAccess<'de>,
- {
- let mut vec = Vec::new();
- while let Some(elem) = seq.next_element()? {
- vec.push(elem);
- }
- Ok(vec)
- }
- }
-
- deserializer.deserialize_any(StringOrVec)
-}
-
#[cfg(not(test))]
use etcetera::base_strategy::{BaseStrategy, choose_base_strategy};
@@ -160,9 +122,8 @@ pub enum StageMode {
/// worktree-path = "../worktrees/{{ repo }}/{{ branch | sanitize }}"
///
/// # Commit generation configuration
-/// [commit-generation]
-/// command = "llm" # Command to invoke for generating commit messages (e.g., "llm", "claude")
-/// args = ["-s"] # Arguments to pass to the command
+/// [commit.generation]
+/// command = "llm -m claude-haiku-4.5" # Shell command for generating commit messages
///
/// # Per-project configuration
/// [projects."github.com/user/repo"]
@@ -175,7 +136,7 @@ pub enum StageMode {
/// - Windows: `%APPDATA%\worktrunk\config.toml`
///
/// Environment variables can override config file settings using `WORKTRUNK_` prefix with
-/// `__` separator for nested fields (e.g., `WORKTRUNK_COMMIT_GENERATION__COMMAND`).
+/// `__` separator for nested fields (e.g., `WORKTRUNK_COMMIT__GENERATION__COMMAND`).
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct UserConfig {
#[serde(
@@ -185,8 +146,16 @@ pub struct UserConfig {
)]
pub(crate) worktree_path: Option<String>,
- #[serde(default, rename = "commit-generation")]
- pub commit_generation: CommitGenerationConfig,
+ /// **DEPRECATED**: Use `[commit.generation]` instead.
+ ///
+ /// This field is kept for backward compatibility. When both are set,
+ /// `commit.generation` takes precedence.
+ #[serde(
+ default,
+ rename = "commit-generation",
+ skip_serializing_if = "Option::is_none"
+ )]
+ pub commit_generation: Option<CommitGenerationConfig>,
/// Per-project configuration (approved commands, etc.)
/// Uses BTreeMap for deterministic serialization order and better diff readability
@@ -229,17 +198,21 @@ pub struct UserConfig {
}
/// Configuration for commit message generation
+///
+/// The command is a shell string executed via `sh -c`. Environment variables
+/// can be set inline (e.g., `MAX_THINKING_TOKENS=0 claude -p ...`).
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq)]
pub struct CommitGenerationConfig {
- /// Command to invoke for generating commit messages (e.g., "llm", "claude")
+ /// Shell command to invoke for generating commit messages
+ ///
+ /// Examples:
+ /// - `"llm -m claude-haiku-4.5"`
+ /// - `"MAX_THINKING_TOKENS=0 claude -p --model haiku"`
+ ///
+ /// The command receives the prompt via stdin and should output the commit message.
#[serde(default)]
pub command: Option<String>,
- /// Arguments to pass to the command
- /// Accepts either an array or a single string (for env var compatibility)
- #[serde(default, deserialize_with = "deserialize_string_or_vec")]
- pub args: Vec<String>,
-
/// Inline template for commit message prompt
/// Available variables: {{ git_diff }}, {{ branch }}, {{ recent_commits }}, {{ repo }}
#[serde(default)]
@@ -296,12 +269,6 @@ impl Merge for CommitGenerationConfig {
Self {
command: other.command.clone().or_else(|| self.command.clone()),
- // For args: use other's if non-empty, else self's
- args: if other.args.is_empty() {
- self.args.clone()
- } else {
- other.args.clone()
- },
template,
template_file,
squash_template,
@@ -322,9 +289,8 @@ impl Merge for CommitGenerationConfig {
/// worktree-path = ".worktrees/{{ branch | sanitize }}"
/// approved-commands = ["npm install", "npm test"]
///
-/// [projects."github.com/user/repo".commit-generation]
-/// command = "llm"
-/// args = ["-m", "gpt-4"]
+/// [projects."github.com/user/repo".commit.generation]
+/// command = "llm -m gpt-4"
///
/// [projects."github.com/user/repo".list]
/// full = true
@@ -350,7 +316,9 @@ pub struct UserProjectOverrides {
)]
pub approved_commands: Vec<String>,
- /// Per-project commit generation settings (overrides global [commit-generation])
+ /// **DEPRECATED**: Use `commit.generation` instead.
+ ///
+ /// Per-project commit generation settings (overrides global `[commit.generation]`)
#[serde(
default,
rename = "commit-generation",
@@ -429,12 +397,24 @@ pub struct CommitConfig {
/// Values: "all", "tracked", "none"
#[serde(skip_serializing_if = "Option::is_none")]
pub stage: Option<StageMode>,
+
+ /// LLM commit message generation settings
+ ///
+ /// Nested under `[commit.generation]` in TOML.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub generation: Option<CommitGenerationConfig>,
}
impl Merge for CommitConfig {
fn merge_with(&self, other: &Self) -> Self {
Self {
stage: other.stage.or(self.stage),
+ generation: match (&self.generation, &other.generation) {
+ (None, None) => None,
+ (Some(s), None) => Some(s.clone()),
+ (None, Some(o)) => Some(o.clone()),
+ (Some(s), Some(o)) => Some(s.merge_with(o)),
+ },
}
}
}
@@ -525,14 +505,32 @@ impl UserConfig {
///
/// Merges project-specific settings with global settings, where project
/// settings take precedence for fields that are set.
+ ///
+ /// Checks locations in order of precedence:
+ /// 1. `[commit.generation]` (new format)
+ /// 2. `[commit-generation]` (deprecated format)
+ /// 3. Per-project overrides
pub fn commit_generation(&self, project: Option<&str>) -> CommitGenerationConfig {
- let global = &self.commit_generation;
- match project
- .and_then(|p| self.projects.get(p))
- .and_then(|c| c.commit_generation.as_ref())
- {
- Some(project_config) => global.merge_with(project_config),
- None => global.clone(),
+ // Get global config: prefer new location, fall back to deprecated
+ let global = self
+ .commit
+ .as_ref()
+ .and_then(|c| c.generation.as_ref())
+ .or(self.commit_generation.as_ref())
+ .cloned()
+ .unwrap_or_default();
+
+ // Get project override (also checks both locations)
+ let project_config = project.and_then(|p| self.projects.get(p)).and_then(|c| {
+ c.commit
+ .as_ref()
+ .and_then(|cc| cc.generation.as_ref())
+ .or(c.commit_generation.as_ref())
+ });
+
+ match project_config {
+ Some(pc) => global.merge_with(pc),
+ None => global,
}
}
@@ -576,17 +574,10 @@ impl UserConfig {
/// 2. Config file (see struct documentation for platform-specific paths)
/// 3. Environment variables (WORKTRUNK_*)
pub fn load() -> Result<Self, ConfigError> {
- let defaults = Self::default();
-
// Note: worktree-path has no default set here - it's handled by the getter
// which returns the default when None. This allows us to distinguish
// "user explicitly set this" from "using default".
- let mut builder = Config::builder()
- .set_default(
- "commit-generation.command",
- defaults.commit_generation.command.unwrap_or_default(),
- )?
- .set_default("commit-generation.args", defaults.commit_generation.args)?;
+ let mut builder = Config::builder();
// Add config file if it exists
let config_path = get_config_path();
@@ -608,7 +599,12 @@ impl UserConfig {
// Warn about unknown fields in the config file
// (must check file content directly, not config.unknown, because
// config.unknown includes env vars which shouldn't trigger warnings)
- let unknown_keys = find_unknown_keys(&content);
+ let unknown_keys: std::collections::HashMap<_, _> = find_unknown_keys(&content)
+ .into_iter()
+ .filter(|(k, _)| {
+ !super::deprecation::DEPRECATED_SECTION_KEYS.contains(&k.as_str())
+ })
+ .collect();
super::deprecation::warn_unknown_fields::<UserConfig>(
config_path,
&unknown_keys,
@@ -621,7 +617,7 @@ impl UserConfig {
// Add environment variables with WORKTRUNK prefix
// - prefix_separator("_"): strip prefix with single underscore (WORKTRUNK_ → key)
- // - separator("__"): double underscore for nested fields (COMMIT_GENERATION__COMMAND → commit-generation.command)
+ // - separator("__"): double underscore for nested fields (COMMIT__GENERATION__COMMAND → commit.generation.command)
// - convert_case(Kebab): converts snake_case to kebab-case to match serde field names
// Example: WORKTRUNK_WORKTREE_PATH → worktree-path
builder = builder.add_source(
@@ -670,7 +666,8 @@ impl UserConfig {
}
}
- // Validate commit generation config
+ // Validate commit generation config (check both old and new locations)
+ // Old: [projects."...".commit-generation] (deprecated)
if let Some(ref cg) = project_config.commit_generation {
if cg.template.is_some() && cg.template_file.is_some() {
return Err(ConfigError::Message(format!(
@@ -683,22 +680,34 @@ impl UserConfig {
)));
}
}
+ // New: [projects."...".commit.generation]
+ if let Some(ref commit) = project_config.commit
+ && let Some(ref cg) = commit.generation
+ {
+ if cg.template.is_some() && cg.template_file.is_some() {
+ return Err(ConfigError::Message(format!(
+ "projects.{project}.commit.generation.template and template-file are mutually exclusive"
+ )));
+ }
+ if cg.squash_template.is_some() && cg.squash_template_file.is_some() {
+ return Err(ConfigError::Message(format!(
+ "projects.{project}.commit.generation.squash-template and squash-template-file are mutually exclusive"
+ )));
+ }
+ }
}
- // Validate commit generation config
- if self.commit_generation.template.is_some()
- && self.commit_generation.template_file.is_some()
- {
+ // Validate commit generation config (check both old and new locations)
+ let commit_gen = self.commit_generation(None);
+ if commit_gen.template.is_some() && commit_gen.template_file.is_some() {
return Err(ConfigError::Message(
- "commit-generation.template and commit-generation.template-file are mutually exclusive".into(),
+ "commit.generation.template and commit.generation.template-file are mutually exclusive".into(),
));
}
- if self.commit_generation.squash_template.is_some()
- && self.commit_generation.squash_template_file.is_some()
- {
+ if commit_gen.squash_template.is_some() && commit_gen.squash_template_file.is_some() {
return Err(ConfigError::Message(
- "commit-generation.squash-template and commit-generation.squash-template-file are mutually exclusive".into(),
+ "commit.generation.squash-template and commit.generation.squash-template-file are mutually exclusive".into(),
));
}
@@ -1117,12 +1126,25 @@ impl UserConfig {
doc["skip-shell-integration-prompt"] = toml_edit::value(true);
}
- // commit-generation section
- doc["commit-generation"] = toml_edit::Item::Table(toml_edit::Table::new());
- let commit_args: toml_edit::Array = self.commit_generation.args.iter().collect();
- doc["commit-generation"]["args"] = toml_edit::value(commit_args);
- if let Some(ref cmd) = self.commit_generation.command {
- doc["commit-generation"]["command"] = toml_edit::value(cmd);
+ // commit.generation section (new format)
+ if let Some(ref commit) = self.commit
+ && let Some(ref generation) = commit.generation
+ && (generation.command.is_some() || generation.template.is_some())
+ {
+ doc["commit"] = toml_edit::Item::Table(toml_edit::Table::new());
+ doc["commit"]["generation"] = toml_edit::Item::Table(toml_edit::Table::new());
+ if let Some(ref cmd) = generation.command {
+ doc["commit"]["generation"]["command"] = toml_edit::value(cmd);
+ }
+ }
+ // Also serialize deprecated commit_generation if present (for backward compat)
+ if let Some(ref generation) = self.commit_generation
+ && generation.command.is_some()
+ {
+ doc["commit-generation"] = toml_edit::Item::Table(toml_edit::Table::new());
+ if let Some(ref cmd) = generation.command {
+ doc["commit-generation"]["command"] = toml_edit::value(cmd);
+ }
}
// projects section with multiline arrays
@@ -1205,7 +1227,7 @@ pub fn get_config_path() -> Option<PathBuf> {
}
}
-/// Find unknown keys in user config TOML content
+/// Find unknown keys in user config TOML content.
///
/// Returns a map of unrecognized top-level keys (with their values) that will be ignored.
/// Uses serde deserialization with flatten to automatically detect unknown fields.
@@ -1509,7 +1531,7 @@ rename-tab = "echo 'switched'"
assert!(config.list.is_none());
assert!(config.commit.is_none());
assert!(config.merge.is_none());
- assert!(!config.commit_generation.is_configured());
+ assert!(config.commit_generation.is_none());
assert!(!config.skip_shell_integration_prompt);
}
@@ -1632,35 +1654,6 @@ rename-tab = "echo 'switched'"
assert_eq!(path, ".worktrees/feature");
}
- #[test]
- fn test_deserialize_string_or_vec_from_string() {
- #[derive(serde::Deserialize)]
- struct Test {
- #[serde(deserialize_with = "deserialize_string_or_vec")]
- args: Vec<String>,
- }
-
- let json = r#"{"args": "single"}"#;
- let parsed: Test = serde_json::from_str(json).unwrap();
- assert_eq!(parsed.args, vec!["single".to_string()]);
- }
-
- #[test]
- fn test_deserialize_string_or_vec_from_array() {
- #[derive(serde::Deserialize)]
- struct Test {
- #[serde(deserialize_with = "deserialize_string_or_vec")]
- args: Vec<String>,
- }
-
- let json = r#"{"args": ["one", "two", "three"]}"#;
- let parsed: Test = serde_json::from_str(json).unwrap();
- assert_eq!(
- parsed.args,
- vec!["one".to_string(), "two".to_string(), "three".to_string()]
- );
- }
-
#[test]
fn test_merge_config_serde() {
let config = MergeConfig {
@@ -1754,15 +1747,88 @@ worktree-path = "../{{ main_worktree }}.{{ branch }}"
fn test_merge_commit_config() {
let base = CommitConfig {
stage: Some(StageMode::All),
+ generation: None,
};
let override_config = CommitConfig {
stage: Some(StageMode::Tracked),
+ generation: None,
};
let merged = base.merge_with(&override_config);
assert_eq!(merged.stage, Some(StageMode::Tracked));
}
+ #[test]
+ fn test_merge_commit_config_generation_base_only() {
+ // Base has generation, override doesn't - use base
+ let base = CommitConfig {
+ stage: None,
+ generation: Some(CommitGenerationConfig {
+ command: Some("base-llm".to_string()),
+ ..Default::default()
+ }),
+ };
+ let override_config = CommitConfig {
+ stage: None,
+ generation: None,
+ };
+
+ let merged = base.merge_with(&override_config);
+ assert_eq!(
+ merged.generation.as_ref().unwrap().command,
+ Some("base-llm".to_string())
+ );
+ }
+
+ #[test]
+ fn test_merge_commit_config_generation_override_only() {
+ // Override has generation, base doesn't - use override
+ let base = CommitConfig {
+ stage: None,
+ generation: None,
+ };
+ let override_config = CommitConfig {
+ stage: None,
+ generation: Some(CommitGenerationConfig {
+ command: Some("override-llm".to_string()),
+ ..Default::default()
+ }),
+ };
+
+ let merged = base.merge_with(&override_config);
+ assert_eq!(
+ merged.generation.as_ref().unwrap().command,
+ Some("override-llm".to_string())
+ );
+ }
+
+ #[test]
+ fn test_merge_commit_config_generation_both() {
+ // Both have generation - merge them
+ let base = CommitConfig {
+ stage: Some(StageMode::All),
+ generation: Some(CommitGenerationConfig {
+ command: Some("base-llm".to_string()),
+ template: Some("base-template".to_string()),
+ ..Default::default()
+ }),
+ };
+ let override_config = CommitConfig {
+ stage: None, // Will use base's stage
+ generation: Some(CommitGenerationConfig {
+ command: Some("override-llm".to_string()), // Override command
+ template: None, // Use base's template
+ ..Default::default()
+ }),
+ };
+
+ let merged = base.merge_with(&override_config);
+ assert_eq!(merged.stage, Some(StageMode::All));
+ let generation = merged.generation.as_ref().unwrap();
+ assert_eq!(generation.command, Some("override-llm".to_string()));
+ assert_eq!(generation.template, Some("base-template".to_string()));
+ }
+
#[test]
fn test_merge_merge_config() {
let base = MergeConfig {
@@ -1791,25 +1857,22 @@ worktree-path = "../{{ main_worktree }}.{{ branch }}"
#[test]
fn test_merge_commit_generation_config() {
let base = CommitGenerationConfig {
- command: Some("llm".to_string()),
- args: vec!["-s".to_string()],
+ command: Some("llm -m claude-haiku-4.5".to_string()),
template: None,
template_file: Some("~/.config/template.txt".to_string()),
squash_template: None,
squash_template_file: None,
};
let override_config = CommitGenerationConfig {
- command: Some("claude".to_string()), // Override
- args: vec![], // Empty = fall back to base
- template: Some("custom".to_string()), // Override (was None)
- template_file: None, // Fall back to base
+ command: Some("claude -p --model haiku".to_string()), // Override
+ template: Some("custom".to_string()), // Override (was None)
+ template_file: None, // Fall back to base
squash_template: None,
squash_template_file: None,
};
let merged = base.merge_with(&override_config);
- assert_eq!(merged.command, Some("claude".to_string()));
- assert_eq!(merged.args, vec!["-s".to_string()]); // Base, since override was empty
+ assert_eq!(merged.command, Some("claude -p --model haiku".to_string()));
assert_eq!(merged.template, Some("custom".to_string()));
// When project sets template, template_file is cleared to maintain mutual exclusivity
assert_eq!(merged.template_file, None);
@@ -1858,14 +1921,57 @@ worktree-path = "../{{ main_worktree }}.{{ branch }}"
assert_eq!(merged.template_file, None);
}
+ #[test]
+ fn test_commit_generation_merge_squash_template_mutual_exclusivity() {
+ // Global has squash_template_file, project has squash_template
+ // Merged result should only have squash_template (project wins)
+ let global = CommitGenerationConfig {
+ squash_template_file: Some("~/.config/squash.txt".to_string()),
+ ..Default::default()
+ };
+ let project = CommitGenerationConfig {
+ squash_template: Some("inline squash".to_string()),
+ ..Default::default()
+ };
+
+ let merged = global.merge_with(&project);
+ assert_eq!(merged.squash_template, Some("inline squash".to_string()));
+ assert_eq!(merged.squash_template_file, None);
+
+ // Reverse: global has squash_template, project has squash_template_file
+ let global = CommitGenerationConfig {
+ squash_template: Some("global squash".to_string()),
+ ..Default::default()
+ };
+ let project = CommitGenerationConfig {
+ squash_template_file: Some("project-squash.txt".to_string()),
+ ..Default::default()
+ };
+
+ let merged = global.merge_with(&project);
+ assert_eq!(merged.squash_template, None);
+ assert_eq!(
+ merged.squash_template_file,
+ Some("project-squash.txt".to_string())
+ );
+ }
+
// =========================================================================
// Effective config methods tests
// =========================================================================
#[test]
fn test_effective_commit_generation_no_project() {
- let mut config = UserConfig::default();
- config.commit_generation.command = Some("global-llm".to_string());
+ let config = UserConfig {
+ commit: Some(CommitConfig {
+ stage: None,
+ generation: Some(CommitGenerationConfig {
+ command: Some("global-llm".to_string()),
+ ..Default::default()
+ }),
+ }),
+ ..Default::default()
+ };
let effective = config.commit_generation(None);
assert_eq!(effective.command, Some("global-llm".to_string()));
@@ -1873,17 +1979,26 @@ worktree-path = "../{{ main_worktree }}.{{ branch }}"
#[test]
fn test_effective_commit_generation_with_project_override() {
- let mut config = UserConfig::default();
- config.commit_generation.command = Some("global-llm".to_string());
- config.commit_generation.args = vec!["--global".to_string()];
+ let mut config = UserConfig {
+ commit: Some(CommitConfig {
+ stage: None,
+ generation: Some(CommitGenerationConfig {
+ command: Some("global-llm".to_string()),
+ ..Default::default()
+ }),
+ }),
+ ..Default::default()
+ };
config.projects.insert(
"github.com/user/repo".to_string(),
UserProjectOverrides {
- commit_generation: Some(CommitGenerationConfig {
- command: Some("project-llm".to_string()),
- args: vec!["--project".to_string()],
- ..Default::default()
+ commit: Some(CommitConfig {
+ stage: None,
+ generation: Some(CommitGenerationConfig {
+ command: Some("project-llm".to_string()),
+ ..Default::default()
+ }),
}),
..Default::default()
},
@@ -1892,7 +2007,6 @@ worktree-path = "../{{ main_worktree }}.{{ branch }}"
// With project identifier, should merge project config
let effective = config.commit_generation(Some("github.com/user/repo"));
assert_eq!(effective.command, Some("project-llm".to_string()));
- assert_eq!(effective.args, vec!["--project".to_string()]);
// Without project or unknown project, should use global
let effective = config.commit_generation(None);
@@ -1968,6 +2082,7 @@ worktree-path = "../{{ main_worktree }}.{{ branch }}"
let config = UserConfig {
commit: Some(CommitConfig {
stage: Some(StageMode::Tracked),
+ generation: None,
}),
..Default::default()
};
@@ -1985,17 +2100,17 @@ worktree-path = "../{{ main_worktree }}.{{ branch }}"
let config = UserProjectOverrides {
worktree_path: Some(".worktrees/{{ branch }}".to_string()),
approved_commands: vec!["npm install".to_string()],
- commit_generation: Some(CommitGenerationConfig {
- command: Some("llm".to_string()),
- args: vec!["-m".to_string(), "gpt-4".to_string()],
- ..Default::default()
- }),
+ commit_generation: None, // Deprecated field, use commit.generation instead
list: Some(ListConfig {
full: Some(true),
..Default::default()
}),
commit: Some(CommitConfig {
stage: Some(StageMode::Tracked),
+ generation: Some(CommitGenerationConfig {
+ command: Some("llm -m gpt-4".to_string()),
+ ..Default::default()
+ }),
}),
merge: Some(MergeConfig {
squash: Some(false),
@@ -2011,8 +2126,15 @@ worktree-path = "../{{ main_worktree }}.{{ branch }}"
Some(".worktrees/{{ branch }}".to_string())
);
assert_eq!(
- parsed.commit_generation.as_ref().unwrap().command,
- Some("llm".to_string())
+ parsed
+ .commit
+ .as_ref()
+ .unwrap()
+ .generation
+ .as_ref()
+ .unwrap()
+ .command,
+ Some("llm -m gpt-4".to_string())
);
assert_eq!(parsed.list.as_ref().unwrap().full, Some(true));
assert_eq!(
@@ -2024,19 +2146,19 @@ worktree-path = "../{{ main_worktree }}.{{ branch }}"
#[test]
fn test_full_config_with_per_project_sections_serde() {
+ // Test new format: [commit.generation] instead of [commit-generation]
let content = r#"
worktree-path = "../{{ repo }}.{{ branch | sanitize }}"
-[commit-generation]
-command = "llm"
+[commit.generation]
+command = "llm -m claude-haiku-4.5"
[projects."github.com/user/repo"]
worktree-path = ".worktrees/{{ branch | sanitize }}"
approved-commands = ["npm install"]
-[projects."github.com/user/repo".commit-generation]
-command = "claude"
-args = ["--model", "opus"]
+[projects."github.com/user/repo".commit.generation]
+command = "claude -p --model opus"
[projects."github.com/user/repo".list]
full = true
@@ -2052,7 +2174,17 @@ squash = false
config.worktree_path,
Some("../{{ repo }}.{{ branch | sanitize }}".to_string())
);
- assert_eq!(config.commit_generation.command, Some("llm".to_string()));
+ assert_eq!(
+ config
+ .commit
+ .as_ref()
+ .unwrap()
+ .generation
+ .as_ref()
+ .unwrap()
+ .command,
+ Some("llm -m claude-haiku-4.5".to_string())
+ );
// Project config
let project = config.projects.get("github.com/user/repo").unwrap();
@@ -2061,24 +2193,89 @@ squash = false
Some(".worktrees/{{ branch | sanitize }}".to_string())
);
assert_eq!(
- project.commit_generation.as_ref().unwrap().command,
- Some("claude".to_string())
- );
- assert_eq!(
- project.commit_generation.as_ref().unwrap().args,
- vec!["--model".to_string(), "opus".to_string()]
+ project
+ .commit
+ .as_ref()
+ .unwrap()
+ .generation
+ .as_ref()
+ .unwrap()
+ .command,
+ Some("claude -p --model opus".to_string())
);
assert_eq!(project.list.as_ref().unwrap().full, Some(true));
assert_eq!(project.merge.as_ref().unwrap().squash, Some(false));
// Effective config for project
let effective_cg = config.commit_generation(Some("github.com/user/repo"));
- assert_eq!(effective_cg.command, Some("claude".to_string()));
+ assert_eq!(
+ effective_cg.command,
+ Some("claude -p --model opus".to_string())
+ );
let effective_merge = config.merge(Some("github.com/user/repo")).unwrap();
assert_eq!(effective_merge.squash, Some(false));
}
+ #[test]
+ fn test_deprecated_commit_generation_format_serde() {
+ // Test old format: [commit-generation] is still parsed for backward compatibility
+ let content = r#"
+[commit-generation]
+command = "llm -m claude-haiku-4.5"
+
+[projects."github.com/user/repo".commit-generation]
+command = "claude -p --model opus"
+"#;
+
+ let config: UserConfig = toml::from_str(content).unwrap();
+
+ // Old format parsed into commit_generation field
+ assert_eq!(
+ config.commit_generation.as_ref().unwrap().command,
+ Some("llm -m claude-haiku-4.5".to_string())
+ );
+
+ // Project override uses deprecated field
+ let project = config.projects.get("github.com/user/repo").unwrap();
+ assert_eq!(
+ project.commit_generation.as_ref().unwrap().command,
+ Some("claude -p --model opus".to_string())
+ );
+
+ // Effective config uses the deprecated values
+ let effective_cg = config.commit_generation(Some("github.com/user/repo"));
+ assert_eq!(
+ effective_cg.command,
+ Some("claude -p --model opus".to_string())
+ );
+ }
+
+ #[test]
+ fn test_deprecated_commit_generation_with_args_field() {
+ // Test that old format with args field still parses (args is ignored)
+ // This ensures backward compatibility for users who haven't migrated yet
+ let content = r#"
+[commit-generation]
+command = "llm"
+args = ["-m", "claude-haiku-4.5"]
+"#;
+
+ let result: Result<UserConfig, _> = toml::from_str(content);
+ assert!(
+ result.is_ok(),
+ "Old format with args field should parse (args is ignored): {:?}",
+ result.err()
+ );
+
+ let config = result.unwrap();
+ // Command is parsed, args is ignored (struct no longer has args field)
+ assert_eq!(
+ config.commit_generation.as_ref().unwrap().command,
+ Some("llm".to_string())
+ );
+ }
+
// Validation tests
#[test]
@@ -2187,4 +2384,161 @@ squash-template-file = "path/to/file"
let err = result.unwrap_err().to_string();
assert!(err.contains("mutually exclusive"), "{err}");
}
+
+ // New format [commit.generation] validation tests
+
+ #[test]
+ fn test_validation_new_format_template_mutual_exclusivity() {
+ let content = r#"
+[commit.generation]
+template = "inline template"
+template-file = "path/to/file"
+"#;
+ let result = UserConfig::load_from_str(content);
+ assert!(result.is_err());
+ let err = result.unwrap_err().to_string();
+ assert!(err.contains("mutually exclusive"), "{err}");
+ }
+
+ #[test]
+ fn test_validation_new_format_squash_template_mutual_exclusivity() {
+ let content = r#"
+[commit.generation]
+squash-template = "inline template"
+squash-template-file = "path/to/file"
+"#;
+ let result = UserConfig::load_from_str(content);
+ assert!(result.is_err());
+ let err = result.unwrap_err().to_string();
+ assert!(err.contains("mutually exclusive"), "{err}");
+ }
+
+ #[test]
+ fn test_validation_new_format_project_template_mutual_exclusivity() {
+ let content = r#"
+[projects."github.com/user/repo".commit.generation]
+template = "inline template"
+template-file = "path/to/file"
+"#;
+ let result = UserConfig::load_from_str(content);
+ assert!(result.is_err());
+ let err = result.unwrap_err().to_string();
+ assert!(err.contains("mutually exclusive"), "{err}");
+ }
+
+ #[test]
+ fn test_validation_new_format_project_squash_template_mutual_exclusivity() {
+ let content = r#"
+[projects."github.com/user/repo".commit.generation]
+squash-template = "inline template"
+squash-template-file = "path/to/file"
+"#;
+ let result = UserConfig::load_from_str(content);
+ assert!(result.is_err());
+ let err = result.unwrap_err().to_string();
+ assert!(err.contains("mutually exclusive"), "{err}");
+ }
+
+ // =========================================================================
+ // save_to() tests
+ // =========================================================================
+
+ #[test]
+ fn test_save_to_new_file_with_commit_generation() {
+ // Test that save_to() creates a new file with commit.generation section
+ // This exercises the "create from scratch" branch when no existing file exists
+ let dir = tempfile::tempdir().unwrap();
+ let config_path = dir.path().join("config.toml");
+
+ let config = UserConfig {
+ commit: Some(CommitConfig {
+ stage: None,
+ generation: Some(CommitGenerationConfig {
+ command: Some("llm -m haiku".to_string()),
+ ..Default::default()
+ }),
+ }),
+ ..Default::default()
+ };
+
+ config.save_to(&config_path).unwrap();
+
+ let saved = std::fs::read_to_string(&config_path).unwrap();
+ assert!(
+ saved.contains("[commit.generation]"),
+ "Should use new format: {saved}"
+ );
+ assert!(
+ saved.contains("command = \"llm -m haiku\""),
+ "Should contain command: {saved}"
+ );
+ }
+
+ #[test]
+ fn test_save_to_new_file_with_deprecated_commit_generation() {
+ // Test that save_to() serializes deprecated commit_generation field
+ // (for backward compat when loading old configs and re-saving)
+ let dir = tempfile::tempdir().unwrap();
+ let config_path = dir.path().join("config.toml");
+
+ let config = UserConfig {
+ commit_generation: Some(CommitGenerationConfig {
+ command: Some("old-llm".to_string()),
+ ..Default::default()
+ }),
+ ..Default::default()
+ };
+
+ config.save_to(&config_path).unwrap();
+
+ let saved = std::fs::read_to_string(&config_path).unwrap();
+ assert!(
+ saved.contains("[commit-generation]"),
+ "Should use deprecated format: {saved}"
+ );
+ assert!(
+ saved.contains("command = \"old-llm\""),
+ "Should contain command: {saved}"
+ );
+ }
+
+ #[test]
+ fn test_save_to_new_file_with_skip_shell_integration() {
+ // Test skip-shell-integration-prompt is only written when true
+ let dir = tempfile::tempdir().unwrap();
+ let config_path = dir.path().join("config.toml");
+
+ let config = UserConfig {
+ skip_shell_integration_prompt: true,
+ ..Default::default()
+ };
+
+ config.save_to(&config_path).unwrap();
+
+ let saved = std::fs::read_to_string(&config_path).unwrap();
+ assert!(
+ saved.contains("skip-shell-integration-prompt = true"),
+ "Should contain flag: {saved}"
+ );
+ }
+
+ #[test]
+ fn test_save_to_new_file_with_worktree_path() {
+ // Test worktree-path is written when set
+ let dir = tempfile::tempdir().unwrap();
+ let config_path = dir.path().join("config.toml");
+
+ let config = UserConfig {
+ worktree_path: Some("../{{ repo }}.{{ branch }}".to_string()),
+ ..Default::default()
+ };
+
+ config.save_to(&config_path).unwrap();
+
+ let saved = std::fs::read_to_string(&config_path).unwrap();
+ assert!(
+ saved.contains("worktree-path = \"../{{ repo }}.{{ branch }}\""),
+ "Should contain worktree-path: {saved}"
+ );
+ }
}
diff --git a/src/llm.rs b/src/llm.rs
index a88a88ca6..36da3112b 100644
--- a/src/llm.rs
+++ b/src/llm.rs
@@ -1,14 +1,45 @@
use anyhow::Context;
+use shell_escape::escape;
+use std::borrow::Cow;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use worktrunk::config::CommitGenerationConfig;
use worktrunk::git::Repository;
use worktrunk::path::format_path_for_display;
-use worktrunk::shell_exec::Cmd;
+use worktrunk::shell_exec::{Cmd, ShellConfig};
use worktrunk::styling::{eprintln, warning_message};
use minijinja::Environment;
+/// Characters that require shell wrapping when used in a command.
+/// If a command contains any of these, it needs `sh -c '...'` to execute correctly.
+const SHELL_METACHARACTERS: &[char] = &[
+ '&', '|', ';', '<', '>', '$', '`', '\'', '"', '(', ')', '{', '}', '*', '?', '[', ']', '~', '!',
+ '\\',
+];
+
+/// Format a reproduction command, only wrapping with `sh -c` if needed.
+///
+/// Simple commands like `llm -m haiku` are shown as-is.
+/// Complex commands with shell syntax are wrapped: `sh -c 'complex && command'`
+fn format_reproduction_command(base_cmd: &str, llm_command: &str) -> String {
+ let needs_shell = llm_command.contains(SHELL_METACHARACTERS)
+ || llm_command
+ .split_whitespace()
+ .next()
+ .is_some_and(|first| first.contains('='));
+
+ if needs_shell {
+ format!(
+ "{} | sh -c {}",
+ base_cmd,
+ escape(Cow::Borrowed(llm_command))
+ )
+ } else {
+ format!("{} | {}", base_cmd, llm_command)
+ }
+}
+
/// Track whether template-file deprecation warning has been shown this session
static TEMPLATE_FILE_WARNING_SHOWN: AtomicBool = AtomicBool::new(false);
@@ -187,15 +218,6 @@ struct TemplateContext<'a> {
target_branch: Option<&'a str>,
}
-/// Format a command and its arguments into a display string
-fn format_command_display(command: &str, args: &[String]) -> String {
- if args.is_empty() {
- command.to_string()
- } else {
- format!("{} {}", command, args.join(" "))
- }
-}
-
/// Default template for commit message prompts
///
/// Synced to dev/config.example.toml by `cargo test readme_sync`
@@ -259,24 +281,45 @@ const DEFAULT_SQUASH_TEMPLATE: &str = r#"Combine these commits into a single com
/// Execute an LLM command with the given prompt via stdin.
///
+/// The command is a shell string executed via the platform shell (sh on Unix,
+/// Git Bash on Windows), allowing environment variables to be set inline
+/// (e.g., `MAX_THINKING_TOKENS=0 claude -p ...`).
+///
/// This is the canonical way to execute LLM commands in this codebase.
/// All LLM execution should go through this function to maintain consistency.
-fn execute_llm_command(command: &str, args: &[String], prompt: &str) -> anyhow::Result<String> {
+fn execute_llm_command(command: &str, prompt: &str) -> anyhow::Result<String> {
// Log prompt for debugging (Cmd logs the command itself)
log::debug!(" Prompt (stdin):");
for line in prompt.lines() {
log::debug!(" {}", line);
}
- let output = Cmd::new(command)
- .args(args.iter().map(String::as_str))
+ let shell = ShellConfig::get();
+ let output = Cmd::new(shell.executable.to_string_lossy())
+ .args(&shell.args)
+ .arg(command)
.stdin_bytes(prompt)
.run()
.context("Failed to spawn LLM command")?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
- anyhow::bail!("{}", stderr.trim());
+ let stderr = stderr.trim();
+ if stderr.is_empty() {
+ // Fall back to stdout or exit code when stderr is empty
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ let stdout = stdout.trim();
+ if stdout.is_empty() {
+ anyhow::bail!(
+ "LLM command failed with exit code {}",
+ output.status.code().unwrap_or(-1)
+ );
+ } else {
+ anyhow::bail!("{}", stdout);
+ }
+ } else {
+ anyhow::bail!("{}", stderr);
+ }
}
let message = String::from_utf8_lossy(&output.stdout).trim().to_owned();
@@ -414,14 +457,15 @@ pub(crate) fn generate_commit_message(
// Check if commit generation is configured (non-empty command)
if commit_generation_config.is_configured() {
let command = commit_generation_config.command.as_ref().unwrap();
- let args = &commit_generation_config.args;
// Commit generation is explicitly configured - fail if it doesn't work
- let llm_command = format_command_display(command, args);
- return try_generate_commit_message(command, args, commit_generation_config).map_err(|e| {
+ return try_generate_commit_message(command, commit_generation_config).map_err(|e| {
worktrunk::git::GitError::LlmCommandFailed {
- command: llm_command.clone(),
+ command: command.clone(),
error: e.to_string(),
- reproduction_command: Some(format!("wt step commit --show-prompt | {llm_command}")),
+ reproduction_command: Some(format_reproduction_command(
+ "wt step commit --show-prompt",
+ command,
+ )),
}
.into()
});
@@ -459,11 +503,10 @@ pub(crate) fn generate_commit_message(
fn try_generate_commit_message(
command: &str,
- args: &[String],
config: &CommitGenerationConfig,
) -> anyhow::Result<String> {
let prompt = build_commit_prompt(config)?;
- execute_llm_command(command, args, &prompt)
+ execute_llm_command(command, &prompt)
}
/// Build the commit prompt from staged changes.
@@ -524,7 +567,6 @@ pub(crate) fn generate_squash_message(
// Check if commit generation is configured (non-empty command)
if commit_generation_config.is_configured() {
let command = commit_generation_config.command.as_ref().unwrap();
- let args = &commit_generation_config.args;
let prompt = build_squash_prompt(
target_branch,
@@ -535,12 +577,14 @@ pub(crate) fn generate_squash_message(
commit_generation_config,
)?;
- let llm_command = format_command_display(command, args);
- return execute_llm_command(command, args, &prompt).map_err(|e| {
+ return execute_llm_command(command, &prompt).map_err(|e| {
worktrunk::git::GitError::LlmCommandFailed {
- command: llm_command.clone(),
+ command: command.clone(),
error: e.to_string(),
- reproduction_command: Some(format!("wt step squash --show-prompt | {llm_command}")),
+ reproduction_command: Some(format_reproduction_command(
+ "wt step squash --show-prompt",
+ command,
+ )),
}
.into()
});
@@ -627,12 +671,11 @@ pub(crate) fn test_commit_generation(
) -> anyhow::Result<String> {
if !commit_generation_config.is_configured() {
anyhow::bail!(
- "Commit generation is not configured. Add [commit-generation] to the config."
+ "Commit generation is not configured. Add [commit.generation] to the config."
);
}
let command = commit_generation_config.command.as_ref().unwrap();
- let args = &commit_generation_config.args;
// Build prompt with synthetic data
let recent_commits = vec![
@@ -651,9 +694,9 @@ pub(crate) fn test_commit_generation(
};
let prompt = build_prompt(commit_generation_config, TemplateType::Commit, &context)?;
- execute_llm_command(command, args, &prompt).map_err(|e| {
+ execute_llm_command(command, &prompt).map_err(|e| {
worktrunk::git::GitError::LlmCommandFailed {
- command: format_command_display(command, args),
+ command: command.clone(),
error: e.to_string(),
reproduction_command: None, // Already a test command
}
@@ -748,7 +791,6 @@ mod tests {
fn test_build_commit_prompt_with_custom_template() {
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: Some("Branch: {{ branch }}\nDiff: {{ git_diff }}".to_string()),
template_file: None,
squash_template: None,
@@ -764,7 +806,6 @@ mod tests {
fn test_build_commit_prompt_malformed_jinja() {
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: Some("{{ unclosed".to_string()),
template_file: None,
squash_template: None,
@@ -779,7 +820,6 @@ mod tests {
fn test_build_commit_prompt_empty_template() {
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: Some(" ".to_string()),
template_file: None,
squash_template: None,
@@ -800,7 +840,6 @@ mod tests {
fn test_build_commit_prompt_with_all_variables() {
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: Some(
"Repo: {{ repo }}\nBranch: {{ branch }}\nDiff: {{ git_diff }}\n{% for c in recent_commits %}{{ c }}\n{% endfor %}"
.to_string(),
@@ -840,7 +879,6 @@ mod tests {
fn test_build_squash_prompt_with_custom_template() {
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: None,
template_file: None,
squash_template: Some(
@@ -870,7 +908,6 @@ mod tests {
fn test_build_squash_prompt_malformed_jinja() {
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: None,
template_file: None,
squash_template: Some("{% for x in commits %}{{ x }".to_string()),
@@ -886,7 +923,6 @@ mod tests {
fn test_build_squash_prompt_empty_template() {
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: None,
template_file: None,
squash_template: Some(" \n ".to_string()),
@@ -909,7 +945,6 @@ mod tests {
// Test that squash templates now have access to ALL variables including git_diff and recent_commits
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: None,
template_file: None,
squash_template: Some(
@@ -942,7 +977,6 @@ mod tests {
// Test advanced jinja features: filters, length, conditionals, whitespace control
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: Some(
r#"=== {{ repo | upper }} ===
Branch: {{ branch }}
@@ -996,7 +1030,6 @@ Diff follows:
// Test the else branch of conditionals
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: Some(
r#"Repo: {{ repo | upper }}
{%- if recent_commits %}
@@ -1025,7 +1058,6 @@ No recent commits
// Test sophisticated jinja in squash templates
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: None,
template_file: None,
squash_template: Some(
@@ -1085,7 +1117,6 @@ Single commit: {{ commits[0] }}
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: None,
template_file: Some(template_path.to_string_lossy().to_string()),
squash_template: None,
@@ -1107,7 +1138,6 @@ Single commit: {{ commits[0] }}
fn test_build_commit_prompt_with_missing_template_file() {
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: None,
template_file: Some("/nonexistent/path/template.txt".to_string()),
squash_template: None,
@@ -1131,7 +1161,6 @@ Single commit: {{ commits[0] }}
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: None,
template_file: None,
squash_template: None,
@@ -1154,7 +1183,6 @@ Single commit: {{ commits[0] }}
// from the expanded home directory path
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: None,
template_file: Some("~/nonexistent_template_for_test.txt".to_string()),
squash_template: None,
@@ -1176,7 +1204,6 @@ Single commit: {{ commits[0] }}
// (they're empty/None for regular commits, but shouldn't cause template errors)
let config = CommitGenerationConfig {
command: None,
- args: vec![],
template: Some(
"Branch: {{ branch }}\nTarget: {{ target_branch }}\nCommits: {{ commits | length }}"
.to_string(),
@@ -1313,26 +1340,6 @@ diff --git a/Cargo.lock b/Cargo.lock
assert!(prepared.diff.contains("files omitted"));
}
- #[test]
- fn test_format_command_display_no_args() {
- let result = format_command_display("echo", &[]);
- assert_eq!(result, "echo");
- }
-
- #[test]
- fn test_format_command_display_with_args() {
- let args = vec!["--model".to_string(), "gpt-4".to_string()];
- let result = format_command_display("llm", &args);
- assert_eq!(result, "llm --model gpt-4");
- }
-
- #[test]
- fn test_format_command_display_single_arg() {
- let args = vec!["--help".to_string()];
- let result = format_command_display("wt", &args);
- assert_eq!(result, "wt --help");
- }
-
#[test]
fn test_parse_diff_sections_empty() {
let sections = parse_diff_sections("");
@@ -1363,4 +1370,41 @@ diff --git a/Cargo.lock b/Cargo.lock
assert!(truncated.contains("line1"));
assert!(truncated.contains("lines omitted"));
}
+
+ #[test]
+ fn test_format_reproduction_command_simple() {
+ // Simple command without shell metacharacters - no wrapping needed
+ let result = format_reproduction_command("git diff", "llm -m haiku");
+ assert_eq!(result, "git diff | llm -m haiku");
+ }
+
+ #[test]
+ fn test_format_reproduction_command_with_env_var() {
+ // Command starting with env var assignment needs shell wrapping
+ let result = format_reproduction_command("git diff", "MAX_THINKING_TOKENS=0 claude -p");
+ assert!(result.contains("sh -c"));
+ assert!(result.contains("git diff |"));
+ }
+
+ #[test]
+ fn test_format_reproduction_command_with_metacharacters() {
+ // Commands with shell metacharacters need wrapping
+ let result = format_reproduction_command("git diff", "cmd1 && cmd2");
+ assert!(result.contains("sh -c"));
+ }
+
+ #[test]
+ fn test_is_lock_file_matches() {
+ assert!(is_lock_file("Cargo.lock"));
+ assert!(is_lock_file("package-lock.json"));
+ assert!(is_lock_file("yarn-lock.yaml"));
+ assert!(is_lock_file("terraform.lock.hcl"));
+ }
+
+ #[test]
+ fn test_is_lock_file_non_matches() {
+ assert!(!is_lock_file("main.rs"));
+ assert!(!is_lock_file("README.md"));
+ assert!(!is_lock_file("config.toml"));
+ }
}
diff --git a/tests/integration_tests/approval_save.rs b/tests/integration_tests/approval_save.rs
index bbd3703df..f59c9f32c 100644
--- a/tests/integration_tests/approval_save.rs
+++ b/tests/integration_tests/approval_save.rs
@@ -32,9 +32,6 @@ fn test_approval_saves_to_disk() {
// Verify TOML structure
let toml_content = fs::read_to_string(&config_path).unwrap();
assert_snapshot!(toml_content, @r#"
- [commit-generation]
- args = []
-
[projects."github.com/test/repo"]
approved-commands = [
"test command",
@@ -85,9 +82,6 @@ fn test_duplicate_approvals_not_saved_twice() {
// Verify file contains only one entry
let toml_content = fs::read_to_string(&config_path).unwrap();
assert_snapshot!(toml_content, @r#"
- [commit-generation]
- args = []
-
[projects."github.com/test/repo"]
approved-commands = [
"test",
@@ -134,9 +128,6 @@ fn test_multiple_project_approvals() {
// Verify file structure
let toml_content = fs::read_to_string(&config_path).unwrap();
assert_snapshot!(toml_content, @r#"
- [commit-generation]
- args = []
-
[projects."github.com/user1/repo1"]
approved-commands = [
"npm install",
@@ -218,10 +209,7 @@ fn test_yes_flag_does_not_save_approval() {
// Load the config and verify it's still empty (no approvals added)
let saved_config = fs::read_to_string(&config_path).unwrap();
- assert_snapshot!(saved_config, @"
- [commit-generation]
- args = []
- ");
+ assert_snapshot!(saved_config, @"");
}
#[test]
@@ -250,9 +238,6 @@ fn test_approval_saves_to_new_config_file() {
// Verify content
let content = fs::read_to_string(&config_path).unwrap();
assert_snapshot!(content, @r#"
- [commit-generation]
- args = []
-
[projects."github.com/test/nested"]
approved-commands = [
"test command",
@@ -275,9 +260,8 @@ fn test_saving_approval_preserves_toml_comments() {
worktree-path = "../{{ main_worktree }}.{{ branch }}"
# LLM commit generation settings
-[commit-generation]
-command = "llm" # inline comment should also be preserved
-args = ["-s"]
+[commit.generation]
+command = "llm -m claude-haiku-4.5" # inline comment should also be preserved
# Per-project settings below
"#;
@@ -656,12 +640,7 @@ fn test_skip_shell_integration_prompt_saves_to_disk() {
// Verify TOML structure
let toml_content = fs::read_to_string(&config_path).unwrap();
- assert_snapshot!(toml_content, @"
- skip-shell-integration-prompt = true
-
- [commit-generation]
- args = []
- ");
+ assert_snapshot!(toml_content, @"skip-shell-integration-prompt = true");
}
#[test]
@@ -709,8 +688,8 @@ fn test_saving_through_symlink_preserves_symlink() {
let initial_content = r#"# My dotfiles config
worktree-path = "../{{ main_worktree }}.{{ branch }}"
-[commit-generation]
-command = "llm"
+[commit.generation]
+command = "llm -m claude-haiku-4.5"
"#;
fs::write(&target_path, initial_content).unwrap();
diff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rs
index 8029e000f..e1d951c54 100644
--- a/tests/integration_tests/config_show.rs
+++ b/tests/integration_tests/config_show.rs
@@ -563,9 +563,8 @@ fn test_config_show_full_command_not_found(mut repo: TestRepo, temp_home: TempDi
&config_path,
r#"worktree-path = "../{{ repo }}.{{ branch }}"
-[commit-generation]
-command = "nonexistent-llm-command-12345"
-args = ["-m", "test-model"]
+[commit.generation]
+command = "nonexistent-llm-command-12345 -m test-model"
"#,
)
.unwrap();
@@ -994,14 +993,8 @@ fn test_deprecated_variables_hint_clear_regenerates(repo: TestRepo, temp_home: T
// Clear the hint
{
let mut cmd = repo.wt_command();
- cmd.args([
- "config",
- "state",
- "hints",
- "clear",
- "deprecated-project-config",
- ])
- .current_dir(repo.root_path());
+ cmd.args(["config", "state", "hints", "clear", "deprecated-config"])
+ .current_dir(repo.root_path());
set_temp_home_env(&mut cmd, temp_home.path());
let output = cmd.output().unwrap();
assert!(
@@ -1242,3 +1235,102 @@ fn test_config_show_claude_available_plugin_not_installed(mut repo: TestRepo, te
assert_cmd_snapshot!(cmd);
});
}
+
+/// Test that deprecated [commit-generation] section shows warning and creates migration file
+#[rstest]
+fn test_deprecated_commit_generation_section_shows_warning(repo: TestRepo, temp_home: TempDir) {
+ // Write user config with deprecated [commit-generation] section
+ let config_path = repo.test_config_path();
+ fs::write(
+ config_path,
+ r#"worktree-path = "../{{ repo }}.{{ branch }}"
+
+[commit-generation]
+command = "llm"
+args = ["-m", "haiku"]
+"#,
+ )
+ .unwrap();
+
+ // Use `wt list` which loads config through UserConfig::load() and triggers deprecation check
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ cmd.arg("list").current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+
+ // Verify migration file was created (config.toml -> config.toml.new)
+ let migration_file = config_path.with_extension("toml.new");
+ assert!(
+ migration_file.exists(),
+ "Migration file should be created at {:?}",
+ migration_file
+ );
+
+ // Verify migration file has correct transformations
+ let migrated_content = fs::read_to_string(&migration_file).unwrap();
+ assert!(
+ migrated_content.contains("[commit.generation]"),
+ "Migration should rename [commit-generation] to [commit.generation]"
+ );
+ assert!(
+ migrated_content.contains("command = \"llm -m haiku\""),
+ "Migration should merge args into command"
+ );
+ assert!(
+ !migrated_content.contains("[commit-generation]"),
+ "Migration should remove old section name"
+ );
+ assert!(
+ !migrated_content.contains("args ="),
+ "Migration should remove args field"
+ );
+}
+
+/// Test that deprecated project-level [projects."...".commit-generation] shows warning
+#[rstest]
+fn test_deprecated_commit_generation_project_level_shows_warning(
+ repo: TestRepo,
+ temp_home: TempDir,
+) {
+ // Write user config with deprecated project-level commit-generation
+ let config_path = repo.test_config_path();
+ fs::write(
+ config_path,
+ r#"worktree-path = "../{{ repo }}.{{ branch }}"
+
+[projects."github.com/example/repo".commit-generation]
+command = "llm -m gpt-4"
+"#,
+ )
+ .unwrap();
+
+ // Use `wt list` which loads config through UserConfig::load() and triggers deprecation check
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ cmd.arg("list").current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+
+ // Verify migration file was created and has correct transformations
+ let migration_file = config_path.with_extension("toml.new");
+ assert!(
+ migration_file.exists(),
+ "Migration file should be created at {:?}",
+ migration_file
+ );
+
+ let migrated_content = fs::read_to_string(&migration_file).unwrap();
+ assert!(
+ migrated_content.contains("[projects.\"github.com/example/repo\".commit.generation]"),
+ "Migration should rename project-level section"
+ );
+}
diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rs
index 6cd26b7bd..82d45c3d5 100644
--- a/tests/integration_tests/merge.rs
+++ b/tests/integration_tests/merge.rs
@@ -318,11 +318,10 @@ fn test_merge_squash_with_llm(mut repo_with_main_worktree: TestRepo) {
);
// Configure mock LLM command via config file
- // Use sh to consume stdin and return a fixed message
+ // Use sh -c to consume stdin and return a fixed message
let worktrunk_config = r#"
-[commit-generation]
-command = "sh"
-args = ["-c", "cat >/dev/null && echo 'feat: implement user authentication system'"]
+[commit.generation]
+command = "cat >/dev/null && echo 'feat: implement user authentication system'"
"#;
fs::write(repo.test_config_path(), worktrunk_config).unwrap();
@@ -347,7 +346,7 @@ fn test_merge_squash_llm_command_not_found(mut repo_with_main_worktree: TestRepo
assert_cmd_snapshot!({
let mut cmd = make_snapshot_cmd(repo, "merge", &["main"], Some(&feature_wt));
cmd.env(
- "WORKTRUNK_COMMIT_GENERATION__COMMAND",
+ "WORKTRUNK_COMMIT__GENERATION__COMMAND",
"nonexistent-llm-command",
);
cmd
@@ -366,14 +365,13 @@ fn test_merge_squash_llm_error(mut repo_with_main_worktree: TestRepo) {
// Configure LLM command via config file with command that will fail
// This tests that:
- // 1. The full command (with args) is shown in the error header
+ // 1. The full command is shown in the error header
// 2. The error output appears in a gutter
// Note: We consume stdin first to avoid race condition where stdin write fails
// before stderr is captured (broken pipe if process exits before reading stdin)
let worktrunk_config = r#"
-[commit-generation]
-command = "sh"
-args = ["-c", "cat > /dev/null; echo 'Error: connection refused' >&2 && exit 1"]
+[commit.generation]
+command = "cat > /dev/null; echo 'Error: connection refused' >&2 && exit 1"
"#;
fs::write(repo.test_config_path(), worktrunk_config).unwrap();
@@ -486,11 +484,10 @@ fn test_merge_auto_commit_with_llm(mut repo_with_main_worktree: TestRepo) {
std::fs::write(feature_wt.join("auth.txt"), "improved auth with validation").unwrap();
// Configure mock LLM command via config file
- // Use sh to consume stdin and return a fixed message (must consume stdin for cross-platform compatibility)
+ // Use sh -c to consume stdin and return a fixed message (must consume stdin for cross-platform compatibility)
let worktrunk_config = r#"
-[commit-generation]
-command = "sh"
-args = ["-c", "cat >/dev/null && echo 'fix: improve auth validation logic'"]
+[commit.generation]
+command = "cat >/dev/null && echo 'fix: improve auth validation logic'"
"#;
fs::write(repo.test_config_path(), worktrunk_config).unwrap();
@@ -512,11 +509,10 @@ fn test_merge_auto_commit_and_squash(repo_with_multi_commit_feature: TestRepo) {
std::fs::write(feature_wt.join("file1.txt"), "updated content 1").unwrap();
// Configure mock LLM command via config file
- // Use sh to consume stdin and return a fixed message (must consume stdin for cross-platform compatibility)
+ // Use sh -c to consume stdin and return a fixed message (must consume stdin for cross-platform compatibility)
let worktrunk_config = r#"
-[commit-generation]
-command = "sh"
-args = ["-c", "cat >/dev/null && echo 'fix: update file 1 content'"]
+[commit.generation]
+command = "cat >/dev/null && echo 'fix: update file 1 content'"
"#;
fs::write(repo.test_config_path(), worktrunk_config).unwrap();
@@ -543,12 +539,10 @@ fn test_merge_with_untracked_files(mut repo_with_main_worktree: TestRepo) {
// Merge - should show warning about untracked files
assert_cmd_snapshot!({
let mut cmd = make_snapshot_cmd(repo, "merge", &["main"], Some(&feature_wt));
- for (key, value) in &[
- ("WORKTRUNK_COMMIT_GENERATION__COMMAND", "echo"),
- ("WORKTRUNK_COMMIT_GENERATION__ARGS", "fix: commit changes"),
- ] {
- cmd.env(key, value);
- }
+ cmd.env(
+ "WORKTRUNK_COMMIT__GENERATION__COMMAND",
+ "cat >/dev/null && echo 'fix: commit changes'",
+ );
cmd
});
}
@@ -1078,7 +1072,7 @@ mod tests {
let llm_path_str = llm_path.to_slash_lossy();
let worktrunk_config = format!(
r#"
-[commit-generation]
+[commit.generation]
command = "{llm_path_str}"
"#
);
@@ -1490,12 +1484,10 @@ fn test_merge_squash_with_working_tree_creates_backup(mut repo_with_main_worktre
// This should create a backup before squashing because there are uncommitted changes
assert_cmd_snapshot!({
let mut cmd = make_snapshot_cmd(repo, "merge", &["main"], Some(&feature_wt));
- for (key, value) in &[
- ("WORKTRUNK_COMMIT_GENERATION__COMMAND", "echo"),
- ("WORKTRUNK_COMMIT_GENERATION__ARGS", "fix: update files"),
- ] {
- cmd.env(key, value);
- }
+ cmd.env(
+ "WORKTRUNK_COMMIT__GENERATION__COMMAND",
+ "cat >/dev/null && echo 'fix: update files'",
+ );
cmd
});
@@ -1585,15 +1577,10 @@ fn test_step_squash_with_no_verify_flag(mut repo: TestRepo) {
assert_cmd_snapshot!({
let mut cmd = make_snapshot_cmd(&repo, "step", &[], Some(&feature_wt));
cmd.arg("squash").args(["--no-verify"]);
- for (key, value) in &[
- ("WORKTRUNK_COMMIT_GENERATION__COMMAND", "echo"),
- (
- "WORKTRUNK_COMMIT_GENERATION__ARGS",
- "squash: combined commits",
- ),
- ] {
- cmd.env(key, value);
- }
+ cmd.env(
+ "WORKTRUNK_COMMIT__GENERATION__COMMAND",
+ "cat >/dev/null && echo 'squash: combined commits'",
+ );
cmd
});
}
@@ -1616,15 +1603,10 @@ fn test_step_squash_with_stage_tracked_flag(mut repo: TestRepo) {
assert_cmd_snapshot!({
let mut cmd = make_snapshot_cmd(&repo, "step", &[], Some(&feature_wt));
cmd.arg("squash").args(["--stage=tracked"]);
- for (key, value) in &[
- ("WORKTRUNK_COMMIT_GENERATION__COMMAND", "echo"),
- (
- "WORKTRUNK_COMMIT_GENERATION__ARGS",
- "squash: combined commits",
- ),
- ] {
- cmd.env(key, value);
- }
+ cmd.env(
+ "WORKTRUNK_COMMIT__GENERATION__COMMAND",
+ "cat >/dev/null && echo 'squash: combined commits'",
+ );
cmd
});
}
@@ -1656,15 +1638,10 @@ fn test_step_squash_with_both_flags(mut repo: TestRepo) {
assert_cmd_snapshot!({
let mut cmd = make_snapshot_cmd(&repo, "step", &[], Some(&feature_wt));
cmd.arg("squash").args(["--no-verify", "--stage=tracked"]);
- for (key, value) in &[
- ("WORKTRUNK_COMMIT_GENERATION__COMMAND", "echo"),
- (
- "WORKTRUNK_COMMIT_GENERATION__ARGS",
- "squash: combined commits",
- ),
- ] {
- cmd.env(key, value);
- }
+ cmd.env(
+ "WORKTRUNK_COMMIT__GENERATION__COMMAND",
+ "cat >/dev/null && echo 'squash: combined commits'",
+ );
cmd
});
}
@@ -1715,12 +1692,10 @@ fn test_step_commit_with_no_verify_flag(repo: TestRepo) {
assert_cmd_snapshot!({
let mut cmd = make_snapshot_cmd(&repo, "step", &[], None);
cmd.arg("commit").args(["--no-verify"]);
- for (key, value) in &[
- ("WORKTRUNK_COMMIT_GENERATION__COMMAND", "echo"),
- ("WORKTRUNK_COMMIT_GENERATION__ARGS", "feat: add file"),
- ] {
- cmd.env(key, value);
- }
+ cmd.env(
+ "WORKTRUNK_COMMIT__GENERATION__COMMAND",
+ "cat >/dev/null && echo 'feat: add file'",
+ );
cmd
});
}
@@ -1740,15 +1715,10 @@ fn test_step_commit_with_stage_tracked_flag(repo: TestRepo) {
assert_cmd_snapshot!({
let mut cmd = make_snapshot_cmd(&repo, "step", &[], None);
cmd.arg("commit").args(["--stage=tracked"]);
- for (key, value) in &[
- ("WORKTRUNK_COMMIT_GENERATION__COMMAND", "echo"),
- (
- "WORKTRUNK_COMMIT_GENERATION__ARGS",
- "fix: update tracked file",
- ),
- ] {
- cmd.env(key, value);
- }
+ cmd.env(
+ "WORKTRUNK_COMMIT__GENERATION__COMMAND",
+ "cat >/dev/null && echo 'fix: update tracked file'",
+ );
cmd
});
}
@@ -1771,12 +1741,10 @@ fn test_step_commit_with_both_flags(repo: TestRepo) {
assert_cmd_snapshot!({
let mut cmd = make_snapshot_cmd(&repo, "step", &[], None);
cmd.arg("commit").args(["--no-verify", "--stage=tracked"]);
- for (key, value) in &[
- ("WORKTRUNK_COMMIT_GENERATION__COMMAND", "echo"),
- ("WORKTRUNK_COMMIT_GENERATION__ARGS", "fix: update file"),
- ] {
- cmd.env(key, value);
- }
+ cmd.env(
+ "WORKTRUNK_COMMIT__GENERATION__COMMAND",
+ "cat >/dev/null && echo 'fix: update file'",
+ );
cmd
});
}
@@ -1784,18 +1752,10 @@ fn test_step_commit_with_both_flags(repo: TestRepo) {
#[rstest]
fn test_step_commit_nothing_to_commit(repo: TestRepo) {
// No changes made - commit should fail with "nothing to commit"
+ // This test doesn't need LLM config since commit fails before generation
assert_cmd_snapshot!({
let mut cmd = make_snapshot_cmd(&repo, "step", &[], None);
cmd.arg("commit").args(["--stage=none"]);
- for (key, value) in &[
- ("WORKTRUNK_COMMIT_GENERATION__COMMAND", "echo"),
- (
- "WORKTRUNK_COMMIT_GENERATION__ARGS",
- "feat: this should fail",
- ),
- ] {
- cmd.env(key, value);
- }
cmd
});
}
diff --git a/tests/integration_tests/readme_sync.rs b/tests/integration_tests/readme_sync.rs
index 4b8a62703..ff19a3c8e 100644
--- a/tests/integration_tests/readme_sync.rs
+++ b/tests/integration_tests/readme_sync.rs
@@ -969,7 +969,7 @@ fn test_config_source_templates_are_in_sync() {
// Format as markdown code block
let replacement = format!(
r#"{prefix}```toml
-[commit-generation]
+[commit.generation]
{key} = """
{template}
"""
diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rs
index 74e1b0297..3bfdbd07d 100644
--- a/tests/integration_tests/shell_wrapper.rs
+++ b/tests/integration_tests/shell_wrapper.rs
@@ -2445,7 +2445,7 @@ def refresh_token(token: str) -> Optional[Dict]:
let worktrunk_config = format!(
r#"worktree-path = "../repo.{{{{ branch }}}}"
-[commit-generation]
+[commit.generation]
command = "{}"
"#,
llm_path.display()
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
index fa9f9b704..4a0ae1537 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
@@ -39,9 +39,8 @@ exit_code: 0
USER CONFIG ~/.config/worktrunk/config.toml
  worktree-path = "../{{ repo }}.{{ branch }}"
 
-  [commit-generation]
-  command = "nonexistent-llm-command-12345"
-  args = ["-m", "test-model"]
+  [commit.generation]
+  command = "nonexistent-llm-command-12345 -m test-model"
PROJECT CONFIG _REPO_/.config/wt.toml
↳ Not found
@@ -58,7 +57,7 @@ exit_code: 0
↳ CI status requires GitHub or GitLab remote
✗ Commit generation failed (nonexistent-llm-command-12345 -m test-model)
  ✗ Commit generation command failed
-    Failed to spawn LLM command
+    sh: nonexistent-llm-command-12345: command not found
  ○ Ran command:
    nonexistent-llm-command-12345 -m test-model
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap
index 3a36037ee..14090e219 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap
@@ -35,6 +35,8 @@ exit_code: 0
----- stdout -----
----- stderr -----
+▲ Project config uses deprecated config sections: [commit-generation] → [commit.generation]
+↳ Wrote migrated wt.toml.new; to apply: mv -- _REPO_/.config/wt.toml.new _REPO_/.config/wt.toml
USER CONFIG ~/.config/worktrunk/config.toml
  worktree-path = "../{{ repo }}.{{ branch }}"
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
index d3d27eb3d..8849df38a 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
@@ -35,6 +35,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
+▲ Project config has unknown field post-merge-command (will be ignored)
USER CONFIG ~/.config/worktrunk/config.toml
  worktree-path = "../{{ repo }}.{{ branch }}"
diff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snap
new file mode 100644
index 000000000..e6e710536
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snap
@@ -0,0 +1,45 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - list
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WT_TEST_DELAYED_STREAM_MS: "-1"
+ WT_TEST_EPOCH: "1735776000"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
+@ main ^| . | 05a4a45d 16h Initial commit
++ feature-a ↑ ↑1 ../repo.feature-a 1b87d473 16h Add feature-a file
++ feature-b ↑ ↑1 ../repo.feature-b f62940fc 16h Add feature-b file
++ feature-c ↑ ↑1 ../repo.feature-c 345c7c93 16h Add feature-c file
+
+○ Showing 4 worktrees, 3 ahead
+
+----- stderr -----
+▲ User config uses deprecated config sections: [projects."github.com/example/repo".commit-generation] → [projects."github.com/example/repo".commit.generation]
+↳ Wrote migrated test-config.toml.new; to apply: mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
diff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snap
new file mode 100644
index 000000000..755bfc650
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snap
@@ -0,0 +1,45 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - list
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WT_TEST_DELAYED_STREAM_MS: "-1"
+ WT_TEST_EPOCH: "1735776000"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
+@ main ^| . | 05a4a45d 16h Initial commit
++ feature-a ↑ ↑1 ../repo.feature-a 1b87d473 16h Add feature-a file
++ feature-b ↑ ↑1 ../repo.feature-b f62940fc 16h Add feature-b file
++ feature-c ↑ ↑1 ../repo.feature-c 345c7c93 16h Add feature-c file
+
+○ Showing 4 worktrees, 3 ahead
+
+----- stderr -----
+▲ User config uses deprecated config sections: [commit-generation] → [commit.generation]
+↳ Wrote migrated test-config.toml.new; to apply: mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
diff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_config_deleted_shows_regenerate_hint.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_config_deleted_shows_regenerate_hint.snap
index ab8232e48..7f3326378 100644
--- a/tests/snapshots/integration__integration_tests__config_show__deprecated_config_deleted_shows_regenerate_hint.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_config_deleted_shows_regenerate_hint.snap
@@ -42,4 +42,4 @@ exit_code: 0
----- stderr -----
▲ Project config uses deprecated template variables: main_worktree → repo
-↳ To regenerate, rerun after wt config state hints clear deprecated-project-config
+↳ To regenerate, rerun after wt config state hints clear deprecated-config
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_create.snap b/tests/snapshots/integration__integration_tests__help__help_config_create.snap
index 972245d47..c85c4521f 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_create.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_create.snap
@@ -10,6 +10,8 @@ info:
CLICOLOR_FORCE: "1"
COLUMNS: "500"
GIT_EDITOR: ""
+ LANG: C
+ LC_ALL: C
RUST_LOG: warn
SHELL: ""
TERM: alacritty
@@ -88,21 +90,9 @@ Creates ~/.config/worktrunk/config.toml with the following content:
#
# ## LLM commit messages
#
- # Generate commit messages automatically during merge. Requires an external CLI tool. See LLM commits docs (https://worktrunk.dev/llm-commits/) for setup and template customization.
+ # Generate commit messages automatically during merge. Requires an external CLI tool.
#
- # Using llm (https://github.com/simonw/llm) (install: `pip install llm llm-anthropic`):
- #
- # [commit-generation]
- # command = "llm"
- # args = ["-m", "claude-haiku-4.5"]
- #
- # Using aichat (https://github.com/sigoden/aichat):
- #
- # [commit-generation]
- # command = "aichat"
- # args = ["-m", "claude:claude-haiku-4.5"]
- #
- # See Custom prompt templates (#custom-prompt-templates) for inline template options.
+ # See LLM commits docs (https://worktrunk.dev/llm-commits/) for setup and Custom prompt templates (#custom-prompt-templates) for template customization.
#
# ## Commands
#
@@ -175,7 +165,7 @@ Creates ~/.config/worktrunk/config.toml with the following content:
# Default template:
#
# <!-- DEFAULT_TEMPLATE_START -->
- # [commit-generation]
+ # [commit.generation]
# template = """
# Write a commit message for the staged changes below.
#
@@ -218,7 +208,7 @@ Creates ~/.config/worktrunk/config.toml with the following content:
# Default template:
#
# <!-- DEFAULT_SQUASH_TEMPLATE_START -->
- # [commit-generation]
+ # [commit.generation]
# squash-template = """
# Combine these commits into a single commit message.
#
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_long.snap b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
index 3be0a17e8..c77dee88f 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
@@ -9,6 +9,8 @@ info:
CLICOLOR_FORCE: "1"
COLUMNS: "500"
GIT_EDITOR: ""
+ LANG: C
+ LC_ALL: C
RUST_LOG: warn
SHELL: ""
TERM: alacritty
@@ -115,21 +117,9 @@ Controls where new worktrees are created. Paths are relative to the repository r
LLM commit messages
-Generate commit messages automatically during merge. Requires an external CLI tool. See LLM commits docs for setup and template customization.
+Generate commit messages automatically during merge. Requires an external CLI tool.
-Using llm (install: pip install llm llm-anthropic):
-
- [commit-generation]
- command = "llm"
- args = ["-m", "claude-haiku-4.5"]
-
-Using aichat:
-
- [commit-generation]
- command = "aichat"
- args = ["-m", "claude:claude-haiku-4.5"]
-
-See Custom prompt templates for inline template options.
+See LLM commits docs for setup and Custom prompt templates for template customization.
Commands
@@ -201,7 +191,7 @@ Available variables:
Default template:
- [commit-generation]
+ [commit.generation]
template = """
Write a commit message for the staged changes below.

@@ -242,7 +232,7 @@ Available variables (in addition to commit template variables):
Default template:
- [commit-generation]
+ [commit.generation]
squash-template = """
Combine these commits into a single commit message.

@@ -347,27 +337,19 @@ Config keys use kebab-case (worktree-path), while env vars use SCREAMING
For nested config sections, use double underscores to separate levels:
- Config Environment Variable
- ───────────────────────── ────────────────────────────────────
- worktree-path WORKTRUNK_WORKTREE_PATH
- commit-generation.command WORKTRUNK_COMMIT_GENERATION__COMMAND
- commit-generation.args WORKTRUNK_COMMIT_GENERATION__ARGS
+ Config Environment Variable
+ ───────────────────────── ─────────────────────────────────────
+ worktree-path WORKTRUNK_WORKTREE_PATH
+ commit.generation.command WORKTRUNK_COMMIT__GENERATION__COMMAND
+ commit.stage WORKTRUNK_COMMIT__STAGE
Note the single underscore after WORKTRUNK and double underscores between nested keys.
-Array values
-
-Array config values like args = ["-m", "claude-haiku"] can be specified as a single string in environment variables:
-
- export WORKTRUNK_COMMIT_GENERATION__ARGS="-m claude-haiku"
-
Example: CI/testing override
Override the LLM command in CI to use a mock:
- WORKTRUNK_COMMIT_GENERATION__COMMAND=echo \
- WORKTRUNK_COMMIT_GENERATION__ARGS="test: automated commit" \
-  wt merge
+ WORKTRUNK_COMMIT__GENERATION__COMMAND="echo 'test: automated commit'" wt merge
Other environment variables
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_command_not_found.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_command_not_found.snap
index bdd4f443c..05d9368d4 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_command_not_found.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_command_not_found.snap
@@ -24,7 +24,7 @@ info:
SHELL: ""
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: nonexistent-llm-command
+ WORKTRUNK_COMMIT__GENERATION__COMMAND: nonexistent-llm-command
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WT_TEST_DELAYED_STREAM_MS: "-1"
@@ -39,6 +39,6 @@ exit_code: 1
◎ Squashing 2 commits into a single commit (2 files, +2)...
◎ Generating squash commit message...
✗ Commit generation command failed
-  Failed to spawn LLM command
+  sh: nonexistent-llm-command: command not found
○ Ran command:
  wt step squash --show-prompt | nonexistent-llm-command
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_error.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_error.snap
index bce3e0591..60295fa4c 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_error.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_error.snap
@@ -40,4 +40,4 @@ exit_code: 1
✗ Commit generation command failed
  Error: connection refused
○ Ran command:
-  wt step squash --show-prompt | sh -c cat > /dev/null; echo 'Error: connection refused' >&2 && exit 1
+  wt step squash --show-prompt | sh -c 'cat > /dev/null; echo '/''Error: connection refused'/'' >&2 && exit 1'
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_with_working_tree_creates_backup.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_with_working_tree_creates_backup.snap
index 0b9cd29db..32082c434 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_with_working_tree_creates_backup.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_with_working_tree_creates_backup.snap
@@ -24,8 +24,7 @@ info:
SHELL: ""
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_COMMIT_GENERATION__ARGS: "fix: update files"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
+ WORKTRUNK_COMMIT_GENERATION__COMMAND: "cat >/dev/null && echo 'fix: update files'"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WT_TEST_DELAYED_STREAM_MS: "-1"
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_with_untracked_files.snap b/tests/snapshots/integration__integration_tests__merge__merge_with_untracked_files.snap
index 6399f9660..e926473cf 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_with_untracked_files.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_with_untracked_files.snap
@@ -24,8 +24,7 @@ info:
SHELL: ""
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_COMMIT_GENERATION__ARGS: "fix: commit changes"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
+ WORKTRUNK_COMMIT_GENERATION__COMMAND: "cat >/dev/null && echo 'fix: commit changes'"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WT_TEST_DELAYED_STREAM_MS: "-1"
diff --git a/tests/snapshots/integration__integration_tests__merge__step_commit_nothing_to_commit.snap b/tests/snapshots/integration__integration_tests__merge__step_commit_nothing_to_commit.snap
index f550cd262..04fa7bb47 100644
--- a/tests/snapshots/integration__integration_tests__merge__step_commit_nothing_to_commit.snap
+++ b/tests/snapshots/integration__integration_tests__merge__step_commit_nothing_to_commit.snap
@@ -25,8 +25,6 @@ info:
SHELL: ""
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_COMMIT_GENERATION__ARGS: "feat: this should fail"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WT_TEST_DELAYED_STREAM_MS: "-1"
diff --git a/tests/snapshots/integration__integration_tests__merge__step_commit_with_both_flags.snap b/tests/snapshots/integration__integration_tests__merge__step_commit_with_both_flags.snap
index 81415627a..363429556 100644
--- a/tests/snapshots/integration__integration_tests__merge__step_commit_with_both_flags.snap
+++ b/tests/snapshots/integration__integration_tests__merge__step_commit_with_both_flags.snap
@@ -26,8 +26,7 @@ info:
SHELL: ""
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_COMMIT_GENERATION__ARGS: "fix: update file"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
+ WORKTRUNK_COMMIT_GENERATION__COMMAND: "cat >/dev/null && echo 'fix: update file'"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WT_TEST_DELAYED_STREAM_MS: "-1"
diff --git a/tests/snapshots/integration__integration_tests__merge__step_commit_with_no_verify_flag.snap b/tests/snapshots/integration__integration_tests__merge__step_commit_with_no_verify_flag.snap
index 13ac501f5..ac3eff206 100644
--- a/tests/snapshots/integration__integration_tests__merge__step_commit_with_no_verify_flag.snap
+++ b/tests/snapshots/integration__integration_tests__merge__step_commit_with_no_verify_flag.snap
@@ -25,8 +25,7 @@ info:
SHELL: ""
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_COMMIT_GENERATION__ARGS: "feat: add file"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
+ WORKTRUNK_COMMIT_GENERATION__COMMAND: "cat >/dev/null && echo 'feat: add file'"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WT_TEST_DELAYED_STREAM_MS: "-1"
diff --git a/tests/snapshots/integration__integration_tests__merge__step_commit_with_stage_tracked_flag.snap b/tests/snapshots/integration__integration_tests__merge__step_commit_with_stage_tracked_flag.snap
index e35f4451a..1f1340fa1 100644
--- a/tests/snapshots/integration__integration_tests__merge__step_commit_with_stage_tracked_flag.snap
+++ b/tests/snapshots/integration__integration_tests__merge__step_commit_with_stage_tracked_flag.snap
@@ -25,8 +25,7 @@ info:
SHELL: ""
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_COMMIT_GENERATION__ARGS: "fix: update tracked file"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
+ WORKTRUNK_COMMIT_GENERATION__COMMAND: "cat >/dev/null && echo 'fix: update tracked file'"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WT_TEST_DELAYED_STREAM_MS: "-1"
diff --git a/tests/snapshots/integration__integration_tests__merge__step_squash_with_both_flags.snap b/tests/snapshots/integration__integration_tests__merge__step_squash_with_both_flags.snap
index 75b2a3b5f..a76c0b265 100644
--- a/tests/snapshots/integration__integration_tests__merge__step_squash_with_both_flags.snap
+++ b/tests/snapshots/integration__integration_tests__merge__step_squash_with_both_flags.snap
@@ -26,8 +26,7 @@ info:
SHELL: ""
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_COMMIT_GENERATION__ARGS: "squash: combined commits"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
+ WORKTRUNK_COMMIT_GENERATION__COMMAND: "cat >/dev/null && echo 'squash: combined commits'"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WT_TEST_DELAYED_STREAM_MS: "-1"
diff --git a/tests/snapshots/integration__integration_tests__merge__step_squash_with_no_verify_flag.snap b/tests/snapshots/integration__integration_tests__merge__step_squash_with_no_verify_flag.snap
index 1cc079c30..e4ad3f756 100644
--- a/tests/snapshots/integration__integration_tests__merge__step_squash_with_no_verify_flag.snap
+++ b/tests/snapshots/integration__integration_tests__merge__step_squash_with_no_verify_flag.snap
@@ -25,8 +25,7 @@ info:
SHELL: ""
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_COMMIT_GENERATION__ARGS: "squash: combined commits"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
+ WORKTRUNK_COMMIT_GENERATION__COMMAND: "cat >/dev/null && echo 'squash: combined commits'"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WT_TEST_DELAYED_STREAM_MS: "-1"
diff --git a/tests/snapshots/integration__integration_tests__merge__step_squash_with_stage_tracked_flag.snap b/tests/snapshots/integration__integration_tests__merge__step_squash_with_stage_tracked_flag.snap
index 935be456c..ac08f7049 100644
--- a/tests/snapshots/integration__integration_tests__merge__step_squash_with_stage_tracked_flag.snap
+++ b/tests/snapshots/integration__integration_tests__merge__step_squash_with_stage_tracked_flag.snap
@@ -25,8 +25,7 @@ info:
SHELL: ""
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_COMMIT_GENERATION__ARGS: "squash: combined commits"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
+ WORKTRUNK_COMMIT_GENERATION__COMMAND: "cat >/dev/null && echo 'squash: combined commits'"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WT_TEST_DELAYED_STREAM_MS: "-1"