Skip to content

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

Feat: Implement custom LLM commit message templates

Maximilian Roos3080a6655000
diff --git a/Cargo.lock b/Cargo.lock
index dff5f584a..872ca56ee 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -584,6 +584,15 @@ dependencies = [
"dirs-sys",
]
+[[package]]
+name = "dirs"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
+dependencies = [
+ "dirs-sys",
+]
+
[[package]]
name = "dirs-sys"
version = "0.5.0"
@@ -1593,6 +1602,15 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
+[[package]]
+name = "shellexpand"
+version = "3.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b1fdf65dd6331831494dd616b30351c38e96e45921a27745cf98490458b90bb"
+dependencies = [
+ "dirs",
+]
+
[[package]]
name = "shlex"
version = "1.3.0"
@@ -2284,6 +2302,7 @@ dependencies = [
"serde",
"serde_json",
"shell-escape",
+ "shellexpand",
"synoptic",
"tempfile",
"terminal_size",
diff --git a/Cargo.toml b/Cargo.toml
index 44690ce8a..425e23e94 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,6 +32,7 @@ rayon = "1.11"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
shell-escape = "0.1"
+shellexpand = "3.1"
synoptic = "2"
terminal_size = "0.4"
toml = "0.9"
diff --git a/config.example.toml b/config.example.toml
index b9a1edca4..86816a55a 100644
--- a/config.example.toml
+++ b/config.example.toml
@@ -17,9 +17,9 @@ worktree-path = "../{main-worktree}.{branch}"
# Alternative: Shared directory for multiple repos
# worktree-path = "../worktrees/{main-worktree}/{branch}"
-# LLM Integration (Optional)
+# Commit Message Generation (Optional)
# For generating commit messages during merge operations (wt merge)
-[llm]
+[commit-generation]
# Example: Simon Willison's llm CLI (https://github.com/simonw/llm)
# Install: pip install llm llm-anthropic
# command = "llm"
@@ -30,6 +30,44 @@ worktree-path = "../{main-worktree}.{branch}"
# command = "aichat"
# args = ["-m", "claude:claude-haiku-4.5"]
+# Optional: Custom prompt template (inline)
+# Available variables: {git-diff}, {branch}, {recent-commits}, {repo}
+# If not specified, uses the default template shown below:
+# template = """
+# Format
+# - First line: <50 chars, present tense, describes WHAT and WHY (not HOW).
+# - Blank line after first line.
+# - Optional details with proper line breaks explaining context. Commits with more substantial changes should have more details.
+# - Return ONLY the formatted message without quotes, code blocks, or preamble.
+#
+# Style
+# - Do not give normative statements or otherwise speculate on why the change was made.
+# - Broadly match the style of the previous commit messages.
+# - For example, if they're in conventional commit format, use conventional commits; if they're not, don't use conventional commits.
+#
+# The context contains:
+# - <git-diff> with the staged changes. This is the ONLY content you should base your message on.
+# - <git-info> with branch name and recent commit message titles for style reference ONLY. DO NOT use their content to inform your message.
+#
+# ---
+# The following is the context for your task:
+# ---
+# <git-diff>
+# ```
+# {git-diff}
+# ```
+# </git-diff>
+#
+# <git-info>
+# <current-branch>{branch}</current-branch>
+# {recent-commits}
+# </git-info>
+# """
+
+# Optional: Load template from file (mutually exclusive with 'template')
+# Supports ~ expansion: ~/.config/worktrunk/commit-template.txt
+# template-file = "~/.config/worktrunk/commit-template.txt"
+
# Approved Commands
# Commands approved for automatic execution after switching worktrees
# Auto-populated when you use: wt switch --execute "command" --force
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index 551dca753..defb5d745 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -11,7 +11,6 @@ pub fn handle_merge(
target: Option<&str>,
squash: bool,
keep: bool,
- message: Option<&str>,
no_hooks: bool,
force: bool,
) -> Result<(), GitError> {
@@ -61,13 +60,13 @@ pub fn handle_merge(
.git_context("Failed to stage changes")?;
} else {
// Commit immediately when not squashing
- handle_commit_changes(message, &config.commit_generation)?;
+ handle_commit_changes(&config.commit_generation)?;
}
}
// Squash commits if requested
if squash {
- handle_squash(&target_branch, message, &config.commit_generation)?;
+ handle_squash(&target_branch, &config.commit_generation)?;
}
// Rebase onto target
@@ -210,7 +209,6 @@ fn format_commit_message_for_display(message: &str) -> String {
/// Commit already-staged changes with an LLM-generated message
fn commit_with_generated_message(
progress_msg: &str,
- custom_instruction: Option<&str>,
commit_generation_config: &worktrunk::config::CommitGenerationConfig,
) -> Result<(), GitError> {
let repo = Repository::current();
@@ -218,8 +216,7 @@ fn commit_with_generated_message(
crate::output::progress(format!("πŸ”„ {CYAN}{progress_msg}{CYAN:#}"))?;
crate::output::progress(format!("πŸ”„ {CYAN}Generating commit message...{CYAN:#}"))?;
- let commit_message =
- crate::llm::generate_commit_message(custom_instruction, commit_generation_config)?;
+ let commit_message = crate::llm::generate_commit_message(commit_generation_config)?;
let formatted_message = format_commit_message_for_display(&commit_message);
crate::output::progress(format_with_gutter(&formatted_message, "", None))?;
@@ -234,7 +231,6 @@ fn commit_with_generated_message(
/// Commit uncommitted changes with LLM-generated message
fn handle_commit_changes(
- custom_instruction: Option<&str>,
commit_generation_config: &worktrunk::config::CommitGenerationConfig,
) -> Result<(), GitError> {
let repo = Repository::current();
@@ -245,14 +241,12 @@ fn handle_commit_changes(
commit_with_generated_message(
"Committing uncommitted changes...",
- custom_instruction,
commit_generation_config,
)
}
fn handle_squash(
target_branch: &str,
- custom_instruction: Option<&str>,
commit_generation_config: &worktrunk::config::CommitGenerationConfig,
) -> Result<Option<usize>, GitError> {
let repo = Repository::current();
@@ -278,11 +272,7 @@ fn handle_squash(
if commit_count == 0 && has_staged {
// Just staged changes, no commits - commit them directly (no squashing needed)
- commit_with_generated_message(
- "Committing staged changes...",
- custom_instruction,
- commit_generation_config,
- )?;
+ commit_with_generated_message("Committing staged changes...", commit_generation_config)?;
return Ok(None);
}
diff --git a/src/config.rs b/src/config.rs
index 4dae8240b..3dcaf3609 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -60,6 +60,16 @@ pub struct CommitGenerationConfig {
/// Arguments to pass to the command
#[serde(default)]
pub args: Vec<String>,
+
+ /// Inline template for commit message prompt
+ /// Available variables: {git-diff}, {branch}, {recent-commits}, {repo}
+ #[serde(default)]
+ pub template: Option<String>,
+
+ /// Path to template file (mutually exclusive with template)
+ /// Supports tilde expansion (e.g., "~/.config/worktrunk/commit-template.txt")
+ #[serde(default, rename = "template-file")]
+ pub template_file: Option<String>,
}
/// Project-specific configuration (stored in .config/wt.toml within the project)
@@ -178,6 +188,15 @@ impl WorktrunkConfig {
));
}
+ // Validate commit generation config
+ if config.commit_generation.template.is_some()
+ && config.commit_generation.template_file.is_some()
+ {
+ return Err(ConfigError::Message(
+ "commit-generation.template and commit-generation.template-file are mutually exclusive".into(),
+ ));
+ }
+
Ok(config)
}
@@ -267,6 +286,52 @@ pub fn expand_template(
result
}
+/// Expand commit template variables
+///
+/// Supported variables:
+/// - `{git-diff}` - Staged changes (diff output)
+/// - `{branch}` - Current branch name
+/// - `{recent-commits}` - Recent commit subjects (formatted, or empty string)
+/// - `{repo}` - Repository name
+///
+/// # Examples
+/// ```
+/// use worktrunk::config::expand_commit_template;
+///
+/// let template = "Changes:\n{git-diff}\n\nBranch: {branch}";
+/// let result = expand_commit_template(template, "diff output", "main", "", "myrepo");
+/// assert_eq!(result, "Changes:\ndiff output\n\nBranch: main");
+/// ```
+pub fn expand_commit_template(
+ template: &str,
+ diff: &str,
+ branch: &str,
+ recent_commits: &str,
+ repo: &str,
+) -> String {
+ template
+ .replace("{git-diff}", diff)
+ .replace("{branch}", branch)
+ .replace("{recent-commits}", recent_commits)
+ .replace("{repo}", repo)
+}
+
+/// Expand tilde in file paths to home directory (cross-platform)
+///
+/// Uses shellexpand for proper tilde expansion following shell conventions.
+///
+/// # Examples
+/// ```
+/// use worktrunk::config::expand_tilde;
+///
+/// let path = expand_tilde("~/config/file.txt");
+/// // Unix: /home/user/config/file.txt
+/// // Windows: C:\Users\user\config\file.txt
+/// ```
+pub fn expand_tilde(path: &str) -> PathBuf {
+ PathBuf::from(shellexpand::tilde(path).as_ref())
+}
+
/// Expand command template variables
///
/// Convenience function for expanding command templates with common variables.
@@ -747,4 +812,86 @@ mod tests {
);
assert_eq!(result, "/path/to/repo/target -> /path/to/worktree/target");
}
+
+ #[test]
+ fn test_expand_commit_template_all_variables() {
+ let template =
+ "Diff: {git-diff}\nBranch: {branch}\nCommits: {recent-commits}\nRepo: {repo}";
+ let result = expand_commit_template(
+ template,
+ "diff content",
+ "feature-x",
+ "- commit1\n- commit2",
+ "myrepo",
+ );
+ assert_eq!(
+ result,
+ "Diff: diff content\nBranch: feature-x\nCommits: - commit1\n- commit2\nRepo: myrepo"
+ );
+ }
+
+ #[test]
+ fn test_expand_commit_template_empty_recent_commits() {
+ let template = "{git-diff}\n{recent-commits}";
+ let result = expand_commit_template(template, "diff", "main", "", "repo");
+ assert_eq!(result, "diff\n");
+ }
+
+ #[test]
+ fn test_expand_tilde_with_home() {
+ // Test that paths starting with ~/ get HOME prepended if HOME is set
+ // We can't set HOME in tests (no unsafe allowed), but we can test the logic
+ let result = expand_tilde("~/config/file.txt");
+ // If HOME is set, result should start with it. If not, it's just the path.
+ // Either way is valid behavior.
+ assert!(result.to_str().unwrap().contains("config/file.txt"));
+ }
+
+ #[test]
+ fn test_expand_tilde_without_tilde() {
+ let result = expand_tilde("/absolute/path");
+ assert_eq!(result, PathBuf::from("/absolute/path"));
+ }
+
+ #[test]
+ fn test_commit_generation_config_mutually_exclusive_validation() {
+ // Test that deserialization rejects both template and template-file
+ let toml_content = r#"
+worktree-path = "../{main-worktree}.{branch}"
+
+[commit-generation]
+command = "llm"
+template = "inline template"
+template-file = "~/file.txt"
+"#;
+
+ // Parse the TOML directly
+ let config_result: Result<WorktrunkConfig, _> = toml::from_str(toml_content);
+
+ // 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 {
+ // 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();
+ assert!(
+ has_both,
+ "Config should have both template fields set for this test"
+ );
+ }
+ }
+
+ #[test]
+ fn test_commit_generation_config_serialization() {
+ let config = CommitGenerationConfig {
+ command: Some("llm".to_string()),
+ args: vec!["-m".to_string(), "model".to_string()],
+ template: Some("template content".to_string()),
+ template_file: None,
+ };
+
+ let toml = toml::to_string(&config).unwrap();
+ assert!(toml.contains("llm"));
+ assert!(toml.contains("template"));
+ }
}
diff --git a/src/llm.rs b/src/llm.rs
index 1045c787b..d26d2902c 100644
--- a/src/llm.rs
+++ b/src/llm.rs
@@ -3,6 +3,37 @@ use std::process::{self, Stdio};
use worktrunk::config::CommitGenerationConfig;
use worktrunk::git::{GitError, Repository};
+/// Default template for commit message prompts
+const DEFAULT_TEMPLATE: &str = r#"Format
+- First line: <50 chars, present tense, describes WHAT and WHY (not HOW).
+- Blank line after first line.
+- Optional details with proper line breaks explaining context. Commits with more substantial changes should have more details.
+- Return ONLY the formatted message without quotes, code blocks, or preamble.
+
+Style
+- Do not give normative statements or otherwise speculate on why the change was made.
+- Broadly match the style of the previous commit messages.
+ - For example, if they're in conventional commit format, use conventional commits; if they're not, don't use conventional commits.
+
+The context contains:
+- <git-diff> with the staged changes. This is the ONLY content you should base your message on.
+- <git-info> with branch name and recent commit message titles for style reference ONLY. DO NOT use their content to inform your message.
+
+---
+The following is the context for your task:
+---
+<git-diff>
+```
+{git-diff}
+```
+</git-diff>
+
+<git-info>
+ <current-branch>{branch}</current-branch>
+{recent-commits}
+</git-info>
+"#;
+
/// Execute an LLM command with the given prompt via stdin.
///
/// This is the canonical way to execute LLM commands in this codebase.
@@ -10,27 +41,18 @@ use worktrunk::git::{GitError, Repository};
fn execute_llm_command(
command: &str,
args: &[String],
- system_instruction: Option<&str>,
prompt: &str,
) -> Result<String, Box<dyn std::error::Error>> {
// Build command args
let mut cmd = process::Command::new(command);
cmd.args(args);
- // Add system instruction if provided
- if let Some(instruction) = system_instruction {
- cmd.arg("--system").arg(instruction);
- }
-
cmd.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
// Log execution
log::debug!("$ {} {}", command, args.join(" "));
- if let Some(instruction) = system_instruction {
- log::debug!(" System: {}", instruction);
- }
log::debug!(" Prompt (stdin):");
for line in prompt.lines() {
log::debug!(" {}", line);
@@ -60,8 +82,72 @@ fn execute_llm_command(
Ok(message)
}
+/// Format recent commits for template expansion
+fn format_recent_commits(commits: Option<&Vec<String>>) -> String {
+ match commits {
+ Some(commits) if !commits.is_empty() => {
+ let mut result = String::from(" <previous-commit-message-titles>\n");
+ for commit in commits {
+ result.push_str(&format!(
+ " <previous-commit-message-title>{}</previous-commit-message-title>\n",
+ commit
+ ));
+ }
+ result.push_str(" </previous-commit-message-titles>");
+ result
+ }
+ _ => String::new(),
+ }
+}
+
+/// Build the commit prompt from config template or default
+fn build_commit_prompt(
+ config: &CommitGenerationConfig,
+ diff: &str,
+ branch: &str,
+ recent_commits: Option<&Vec<String>>,
+ repo_name: &str,
+) -> Result<String, Box<dyn std::error::Error>> {
+ // Get template source
+ let template = match (&config.template, &config.template_file) {
+ (Some(inline), None) => inline.clone(),
+ (None, Some(path)) => {
+ let expanded_path = worktrunk::config::expand_tilde(path);
+ std::fs::read_to_string(&expanded_path).map_err(|e| {
+ format!(
+ "Failed to read template-file '{}': {}",
+ expanded_path.display(),
+ e
+ )
+ })?
+ }
+ (None, None) => DEFAULT_TEMPLATE.to_string(),
+ (Some(_), Some(_)) => {
+ unreachable!("Config validation should prevent both template and template-file")
+ }
+ };
+
+ // Validate non-empty
+ if template.trim().is_empty() {
+ return Err("Template is empty".into());
+ }
+
+ // Format recent commits
+ let recent_commits_formatted = format_recent_commits(recent_commits);
+
+ // Expand variables
+ let expanded = worktrunk::config::expand_commit_template(
+ &template,
+ diff,
+ branch,
+ &recent_commits_formatted,
+ repo_name,
+ );
+
+ Ok(expanded)
+}
+
pub fn generate_commit_message(
- custom_instruction: Option<&str>,
commit_generation_config: &CommitGenerationConfig,
) -> Result<String, GitError> {
// Check if commit generation is configured (non-empty command)
@@ -70,9 +156,9 @@ pub fn generate_commit_message(
{
// Commit generation is explicitly configured - fail if it doesn't work
return try_generate_commit_message(
- custom_instruction,
command,
&commit_generation_config.args,
+ commit_generation_config,
)
.map_err(|e| {
GitError::CommandFailed(format!(
@@ -87,9 +173,9 @@ pub fn generate_commit_message(
}
fn try_generate_commit_message(
- custom_instruction: Option<&str>,
command: &str,
args: &[String],
+ config: &CommitGenerationConfig,
) -> Result<String, Box<dyn std::error::Error>> {
let repo = Repository::current();
@@ -99,6 +185,13 @@ fn try_generate_commit_message(
// Get current branch
let current_branch = repo.current_branch()?.unwrap_or_else(|| "HEAD".to_string());
+ // Get repo name from directory
+ let repo_root = repo.worktree_root()?;
+ let repo_name = repo_root
+ .file_name()
+ .and_then(|n| n.to_str())
+ .unwrap_or("repo");
+
// Get recent commit messages for style reference
let recent_commits = repo
.run_command(&["log", "--pretty=format:%s", "-n", "5", "--no-merges"])
@@ -111,66 +204,16 @@ fn try_generate_commit_message(
}
});
- // Build the prompt following the Fish function format exactly
- let user_instruction = custom_instruction
- .unwrap_or("Write a concise, clear git commit message based on the provided diff.");
-
- let mut prompt = String::new();
-
- // Format section
- prompt.push_str("Format\n");
- prompt.push_str("- First line: <50 chars, present tense, describes WHAT and WHY (not HOW).\n");
- prompt.push_str("- Blank line after first line.\n");
- prompt.push_str("- Optional details with proper line breaks explaining context. Commits with more substantial changes should have more details.\n");
- prompt.push_str(
- "- Return ONLY the formatted message without quotes, code blocks, or preamble.\n",
- );
- prompt.push('\n');
-
- // Style section
- prompt.push_str("Style\n");
- prompt.push_str(
- "- Do not give normative statements or otherwise speculate on why the change was made.\n",
- );
- prompt.push_str("- Broadly match the style of the previous commit messages.\n");
- prompt.push_str(" - For example, if they're in conventional commit format, use conventional commits; if they're not, don't use conventional commits.\n");
- prompt.push('\n');
-
- // Context description
- prompt.push_str("The context contains:\n");
- prompt.push_str("- <git-diff> with the staged changes. This is the ONLY content you should base your message on.\n");
- prompt.push_str("- <git-info> with branch name and recent commit message titles for style reference ONLY. DO NOT use their content to inform your message.\n");
- prompt.push('\n');
- prompt.push_str("---\n");
- prompt.push_str("The following is the context for your task:\n");
- prompt.push_str("---\n");
-
- // Git diff section
- prompt.push_str("<git-diff>\n```\n");
- prompt.push_str(&diff_output);
- prompt.push_str("\n```\n</git-diff>\n\n");
-
- // Git info section
- prompt.push_str("<git-info>\n");
- prompt.push_str(&format!(
- " <current-branch>{}</current-branch>\n",
- current_branch
- ));
-
- if let Some(commits) = recent_commits {
- prompt.push_str(" <previous-commit-message-titles>\n");
- for commit in commits {
- prompt.push_str(&format!(
- " <previous-commit-message-title>{}</previous-commit-message-title>\n",
- commit
- ));
- }
- prompt.push_str(" </previous-commit-message-titles>\n");
- }
-
- prompt.push_str("</git-info>\n\n");
+ // Build prompt from template
+ let prompt = build_commit_prompt(
+ config,
+ &diff_output,
+ &current_branch,
+ recent_commits.as_ref(),
+ repo_name,
+ )?;
- execute_llm_command(command, args, Some(user_instruction), &prompt)
+ execute_llm_command(command, args, &prompt)
}
pub fn generate_squash_message(
@@ -220,5 +263,5 @@ fn try_generate_llm_message(
let prompt = "Generate a conventional commit message (feat/fix/docs/style/refactor) that combines these changes into one cohesive message. Output only the commit message without any explanation.";
let full_prompt = format!("{}\n\n{}", context, prompt);
- execute_llm_command(command, args, None, &full_prompt)
+ execute_llm_command(command, args, &full_prompt)
}
diff --git a/src/main.rs b/src/main.rs
index 4b463f487..478d3fb47 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -155,7 +155,7 @@ The merge operation follows a strict order designed for fail-fast execution:
3. Auto-commit uncommitted changes
If working tree has uncommitted changes, stages all changes (git add -A) and commits
- with LLM-generated message. Custom instructions can be provided via --message.
+ with LLM-generated message.
4. Squash commits
If --squash specified, counts commits since merge base with target branch. When
@@ -197,10 +197,6 @@ Skip pre-merge commands:
#[arg(short, long)]
keep: bool,
- /// Custom instruction for commit message generation
- #[arg(short = 'm', long)]
- message: Option<String>,
-
/// Skip all project hooks (pre-merge-command)
#[arg(long)]
no_hooks: bool,
@@ -435,17 +431,9 @@ fn main() {
target,
squash,
keep,
- message,
- no_hooks,
- force,
- } => handle_merge(
- target.as_deref(),
- squash,
- keep,
- message.as_deref(),
no_hooks,
force,
- ),
+ } => handle_merge(target.as_deref(), squash, keep, no_hooks, force),
Commands::Completion { shell } => {
let mut cli_cmd = Cli::command();
handle_completion(shell, &mut cli_cmd);
diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rs
index 73a59ee7f..19797ae94 100644
--- a/tests/integration_tests/merge.rs
+++ b/tests/integration_tests/merge.rs
@@ -678,59 +678,6 @@ fn test_merge_auto_commit_with_llm() {
);
}
-#[test]
-fn test_merge_auto_commit_with_message() {
- let mut repo = TestRepo::new();
- repo.commit("Initial commit");
- repo.setup_remote("main");
-
- // Create a worktree for main
- let main_wt = repo.root_path().parent().unwrap().join("test-repo.main-wt");
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["worktree", "add", main_wt.to_str().unwrap(), "main"])
- .current_dir(repo.root_path())
- .output()
- .expect("Failed to add worktree");
-
- // Create a feature worktree with a commit
- let feature_wt = repo.add_worktree("feature", "feature");
- std::fs::write(feature_wt.join("feature.txt"), "initial").expect("Failed to write file");
-
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["add", "feature.txt"])
- .current_dir(&feature_wt)
- .output()
- .expect("Failed to add file");
-
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["commit", "-m", "feat: start feature"])
- .current_dir(&feature_wt)
- .output()
- .expect("Failed to commit");
-
- // Add uncommitted tracked changes
- std::fs::write(feature_wt.join("feature.txt"), "completed feature")
- .expect("Failed to write file");
-
- // Merge with -m flag (custom instruction) and LLM configured
- snapshot_merge_with_env(
- "merge_auto_commit_with_message",
- &repo,
- &["main", "-m", "Complete the user dashboard feature"],
- Some(&feature_wt),
- &[
- ("WORKTRUNK_COMMIT_GENERATION__COMMAND", "echo"),
- (
- "WORKTRUNK_COMMIT_GENERATION__ARGS",
- "feat: complete user dashboard",
- ),
- ],
- );
-}
-
#[test]
fn test_merge_auto_commit_and_squash() {
let mut repo = TestRepo::new();
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap
index 5ad7e7d95..fec8f46e4 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpUjqv7W/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpq7zyU8/test-config.toml
---
success: true
exit_code: 0
@@ -342,20 +342,12 @@ _wt() {
return 0
;;
wt__merge)
- opts="-s -k -m -f -v -h --squash --keep --message --no-hooks --force --verbose --help [TARGET]"
+ opts="-s -k -f -v -h --squash --keep --no-hooks --force --verbose --help [TARGET]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
- --message)
- COMPREPLY=($(compgen -f "${cur}"))
- return 0
- ;;
- -m)
- COMPREPLY=($(compgen -f "${cur}"))
- return 0
- ;;
*)
COMPREPLY=()
;;
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap b/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap
index b095266f1..e2e279dba 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap
@@ -18,7 +18,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpI2Bq3O/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpkxrxG1/test-config.toml
---
success: true
exit_code: 0
@@ -344,20 +344,12 @@ _wt() {
return 0
;;
wt__merge)
- opts="-s -k -m -f -v -h --squash --keep --message --no-hooks --force --verbose --help [TARGET]"
+ opts="-s -k -f -v -h --squash --keep --no-hooks --force --verbose --help [TARGET]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
- --message)
- COMPREPLY=($(compgen -f "${cur}"))
- return 0
- ;;
- -m)
- COMPREPLY=($(compgen -f "${cur}"))
- return 0
- ;;
*)
COMPREPLY=()
;;
diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snap
index b0ce3bf08..137bbf0b8 100644
--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpirklUY/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpAwdf0S/test-config.toml
---
success: true
exit_code: 0
@@ -252,7 +252,6 @@ complete -c wt -n "__fish_wt_using_subcommand remove" -s h -l help -d 'Print hel
complete -c wt -n "__fish_wt_using_subcommand push" -l allow-merge-commits -d 'Allow pushing merge commits (non-linear history)'
complete -c wt -n "__fish_wt_using_subcommand push" -s v -l verbose -d 'Enable verbose output (show git commands and debug info)'
complete -c wt -n "__fish_wt_using_subcommand push" -s h -l help -d 'Print help'
-complete -c wt -n "__fish_wt_using_subcommand merge" -s m -l message -d 'Custom instruction for commit message generation' -r
complete -c wt -n "__fish_wt_using_subcommand merge" -s s -l squash -d 'Squash all commits into one before merging'
complete -c wt -n "__fish_wt_using_subcommand merge" -s k -l keep -d 'Keep worktree after merging (don\'t remove)'
complete -c wt -n "__fish_wt_using_subcommand merge" -l no-hooks -d 'Skip all project hooks (pre-merge-command)'
diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
index d933f99f9..3f363f8fe 100644
--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpfnWawP/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpNfo5re/test-config.toml
---
success: true
exit_code: 0
@@ -260,8 +260,6 @@ _arguments "${_arguments_options[@]}" : \
;;
(merge)
_arguments "${_arguments_options[@]}" : \
-'-m+[Custom instruction for commit message generation]:MESSAGE:_default' \
-'--message=[Custom instruction for commit message generation]:MESSAGE:_default' \
'-s[Squash all commits into one before merging]' \
'--squash[Squash all commits into one before merging]' \
'-k[Keep worktree after merging (don'\''t remove)]' \
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_message.snap b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_message.snap
deleted file mode 100644
index 5b52a8c67..000000000
--- a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_message.snap
+++ /dev/null
@@ -1,47 +0,0 @@
----
-source: tests/integration_tests/merge.rs
-info:
- program: wt
- args:
- - merge
- - main
- - "-m"
- - Complete the user dashboard feature
- env:
- CLICOLOR_FORCE: "1"
- COLUMNS: "150"
- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
- GIT_CONFIG_GLOBAL: /dev/null
- GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
- LANG: C
- LC_ALL: C
- SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_COMMIT_GENERATION__ARGS: "feat: complete user dashboard"
- WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpTS5gdO/test-config.toml
----
-success: true
-exit_code: 0
------ stdout -----
-πŸ”„ Committing uncommitted changes...
-πŸ”„ Generating commit message...
-  WIP: Auto-commit before merge
-
-βœ… Committed changes
-πŸ”„ Rebasing onto main...
-πŸ”„ Merging 2 commits to main @ [SHA]
-
-* [SHA] (HEAD -> feature) WIP: Auto-commit before merge
-* [SHA] feat: start feature
-
- feature.txt | 1 +
- 1 file changed, 1 insertion(+)
-
-βœ… Merged to main (2 commits, 1 file, +1) 
-πŸ”„ Cleaning up worktree...
-
-βœ… Returned to primary at [REPO]
-
------ stderr -----