Skip to content

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

feat: Add pre-merge checks to `wt merge` command

Maximilian Roosc24f62df5c6b
diff --git a/src/commands/command_approval.rs b/src/commands/command_approval.rs
new file mode 100644
index 000000000..bcdfd4fe1
--- /dev/null
+++ b/src/commands/command_approval.rs
@@ -0,0 +1,171 @@
+//! Command approval and execution utilities
+//!
+//! This module provides shared functionality for approving and executing commands
+//! across different worktrunk operations (post-create, post-start, pre-merge).
+
+use worktrunk::config::{CommandConfig, WorktrunkConfig};
+use worktrunk::git::GitError;
+use worktrunk::styling::{AnstyleStyle, HINT_EMOJI, WARNING, WARNING_EMOJI};
+
+/// Convert CommandConfig to a vector of (name, command) pairs
+///
+/// # Arguments
+/// * `config` - The command configuration to convert
+/// * `default_prefix` - Prefix for unnamed commands (typically "cmd")
+///
+/// # Naming Behavior
+/// - **Single string**: Uses the exact prefix without numbering
+/// - `pre-merge-check = "exit 0"` → `("cmd", "exit 0")`
+/// - **Array (even single-element)**: Appends 1-based index to prefix
+/// - `pre-merge-check = ["exit 0"]` → `("cmd-1", "exit 0")`
+/// - `pre-merge-check = ["a", "b"]` → `("cmd-1", "a"), ("cmd-2", "b")`
+/// - **Named table**: Uses the key names directly (sorted alphabetically)
+/// - `[pre-merge-check]` `foo="a"` `bar="b"` → `("bar", "b"), ("foo", "a")`
+pub fn command_config_to_vec(
+ config: &CommandConfig,
+ default_prefix: &str,
+) -> Vec<(String, String)> {
+ match config {
+ CommandConfig::Single(cmd) => vec![(default_prefix.to_string(), cmd.clone())],
+ CommandConfig::Multiple(cmds) => cmds
+ .iter()
+ .enumerate()
+ .map(|(i, cmd)| (format!("{}-{}", default_prefix, i + 1), cmd.clone()))
+ .collect(),
+ CommandConfig::Named(map) => {
+ let mut pairs: Vec<_> = map.iter().map(|(k, v)| (k.clone(), v.clone())).collect();
+ // Sort by name for deterministic iteration order
+ pairs.sort_by(|a, b| a.0.cmp(&b.0));
+ pairs
+ }
+ }
+}
+
+/// Check if command is approved and prompt if needed
+///
+/// Returns `Ok(true)` if the command is approved (either already approved or user approved it),
+/// `Ok(false)` if the user declined, or `Err` if there was a system error.
+pub fn check_and_approve_command(
+ project_id: &str,
+ command: &str,
+ config: &WorktrunkConfig,
+ force: bool,
+) -> Result<bool, GitError> {
+ if force || config.is_command_approved(project_id, command) {
+ return Ok(true);
+ }
+
+ match prompt_for_approval(command, project_id) {
+ Ok(true) => {
+ // Reload config and save approval
+ match WorktrunkConfig::load() {
+ Ok(mut fresh_config) => {
+ if let Err(e) =
+ fresh_config.approve_command(project_id.to_string(), command.to_string())
+ {
+ use worktrunk::styling::eprintln;
+ eprintln!(
+ "{WARNING_EMOJI} {WARNING}Failed to save command approval: {e}{WARNING:#}"
+ );
+ eprintln!("You will be prompted again next time.");
+ }
+ }
+ Err(e) => {
+ use worktrunk::styling::eprintln;
+ eprintln!(
+ "{WARNING_EMOJI} {WARNING}Failed to reload config for saving approval: {e}{WARNING:#}"
+ );
+ eprintln!("You will be prompted again next time.");
+ }
+ }
+ Ok(true)
+ }
+ Ok(false) => Ok(false),
+ Err(e) => {
+ use worktrunk::styling::eprintln;
+ eprintln!("{WARNING_EMOJI} {WARNING}Failed to read user input: {e}{WARNING:#}");
+ Ok(false)
+ }
+ }
+}
+
+/// Prompt the user to approve a command for execution
+///
+/// Displays a formatted prompt asking the user to approve a command,
+/// showing both the project and the command being requested.
+fn prompt_for_approval(command: &str, project_id: &str) -> std::io::Result<bool> {
+ use std::io::{self, Write};
+ use worktrunk::styling::eprintln;
+
+ // Extract just the project name for cleaner display
+ let project_name = project_id.split('/').next_back().unwrap_or(project_id);
+
+ let bold = AnstyleStyle::new().bold();
+ let dim = AnstyleStyle::new().dimmed();
+
+ eprintln!();
+ eprintln!("{WARNING_EMOJI} {WARNING}Permission required to execute in worktree{WARNING:#}");
+ eprintln!();
+ eprintln!(" {bold}{project_name}{bold:#} ({dim}{project_id}{dim:#}) wants to execute:");
+ eprintln!(" {dim}{command}{dim:#}");
+ eprintln!();
+ eprint!(" {HINT_EMOJI} Allow and remember? {bold}[y/N]{bold:#} ");
+ io::stderr().flush()?;
+
+ let mut response = String::new();
+ io::stdin().read_line(&mut response)?;
+
+ Ok(response.trim().eq_ignore_ascii_case("y"))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use std::collections::HashMap;
+
+ #[test]
+ fn test_command_config_to_vec_single() {
+ let config = CommandConfig::Single("echo test".to_string());
+ let result = command_config_to_vec(&config, "cmd");
+ assert_eq!(result, vec![("cmd".to_string(), "echo test".to_string())]);
+ }
+
+ #[test]
+ fn test_command_config_to_vec_multiple() {
+ let config = CommandConfig::Multiple(vec!["cmd1".to_string(), "cmd2".to_string()]);
+ let result = command_config_to_vec(&config, "check");
+ assert_eq!(
+ result,
+ vec![
+ ("check-1".to_string(), "cmd1".to_string()),
+ ("check-2".to_string(), "cmd2".to_string())
+ ]
+ );
+ }
+
+ #[test]
+ fn test_command_config_to_vec_named() {
+ let mut map = HashMap::new();
+ map.insert("zebra".to_string(), "z".to_string());
+ map.insert("alpha".to_string(), "a".to_string());
+ let config = CommandConfig::Named(map);
+ let result = command_config_to_vec(&config, "cmd");
+ // Should be sorted alphabetically
+ assert_eq!(
+ result,
+ vec![
+ ("alpha".to_string(), "a".to_string()),
+ ("zebra".to_string(), "z".to_string())
+ ]
+ );
+ }
+
+ #[test]
+ fn test_command_config_to_vec_different_prefix() {
+ let config = CommandConfig::Single("test".to_string());
+ let result1 = command_config_to_vec(&config, "cmd");
+ let result2 = command_config_to_vec(&config, "check");
+ assert_eq!(result1[0].0, "cmd");
+ assert_eq!(result2[0].0, "check");
+ }
+}
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index ae35a5d46..7362c6889 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -1,17 +1,21 @@
use anstyle::{AnsiColor, Color};
-use worktrunk::config::WorktrunkConfig;
+use std::collections::HashMap;
+use worktrunk::config::{ProjectConfig, WorktrunkConfig, expand_template};
use worktrunk::git::{GitError, Repository};
use worktrunk::styling::{AnstyleStyle, ERROR, ERROR_EMOJI, HINT, HINT_EMOJI, eprintln, println};
+use super::command_approval::{check_and_approve_command, command_config_to_vec};
use super::worktree::handle_push;
use super::worktree::handle_remove;
-use crate::output::handle_remove_output;
+use crate::output::{execute_command_in_worktree, handle_remove_output};
pub fn handle_merge(
target: Option<&str>,
squash: bool,
keep: bool,
message: Option<&str>,
+ no_verify: bool,
+ force: bool,
internal: bool,
) -> Result<(), GitError> {
let repo = Repository::current();
@@ -46,6 +50,22 @@ pub fn handle_merge(
handle_commit_changes(message, &config.llm)?;
}
+ // Run pre-merge checks unless --no-verify was specified
+ if !no_verify && let Ok(Some(project_config)) = ProjectConfig::load(&repo.worktree_root()?) {
+ let worktree_path = std::env::current_dir().map_err(|e| {
+ GitError::CommandFailed(format!("Failed to get current directory: {}", e))
+ })?;
+ run_pre_merge_checks(
+ &project_config,
+ &current_branch,
+ &target_branch,
+ &worktree_path,
+ &repo,
+ &config,
+ force,
+ )?;
+ }
+
// Track operations for summary
let mut squashed_count: Option<usize> = None;
@@ -221,3 +241,85 @@ fn handle_squash(target_branch: &str) -> Result<Option<usize>, GitError> {
println!("✅ {green}Squashed {commit_count} commits into one{green:#}");
Ok(Some(commit_count))
}
+
+/// Run pre-merge checks sequentially (blocking, fail-fast)
+fn run_pre_merge_checks(
+ project_config: &ProjectConfig,
+ current_branch: &str,
+ target_branch: &str,
+ worktree_path: &std::path::Path,
+ repo: &Repository,
+ config: &WorktrunkConfig,
+ force: bool,
+) -> Result<(), GitError> {
+ let Some(pre_merge_config) = &project_config.pre_merge_check else {
+ return Ok(());
+ };
+
+ let commands = command_config_to_vec(pre_merge_config, "cmd");
+ if commands.is_empty() {
+ return Ok(());
+ }
+
+ let project_id = repo.project_identifier()?;
+ let repo_root = repo.main_worktree_root()?;
+ let repo_name = repo_root
+ .file_name()
+ .and_then(|n| n.to_str())
+ .unwrap_or("unknown");
+
+ // Execute each command sequentially, fail-fast on errors
+ for (name, command) in commands {
+ if !check_and_approve_command(&project_id, &command, config, force)? {
+ let dim = AnstyleStyle::new().dimmed();
+ eprintln!("{dim}Skipping pre-merge check: {command}{dim:#}");
+ continue;
+ }
+
+ let expanded_command = expand_command_template(
+ &command,
+ repo_name,
+ current_branch,
+ target_branch,
+ worktree_path,
+ &repo_root,
+ );
+
+ use std::io::Write;
+ let cyan = AnstyleStyle::new().fg_color(Some(Color::Ansi(AnsiColor::Cyan)));
+ println!("🔄 {cyan}Running pre-merge check '{name}'...{cyan:#}");
+ let _ = std::io::stdout().flush();
+
+ if let Err(e) = execute_command_in_worktree(worktree_path, &expanded_command) {
+ eprintln!();
+ let error_bold = ERROR.bold();
+ eprintln!(
+ "{ERROR_EMOJI} {ERROR}Pre-merge check failed: {error_bold}{name}{error_bold:#}{ERROR:#}"
+ );
+ eprintln!();
+ eprintln!(" {e}");
+ eprintln!();
+ eprintln!("{HINT_EMOJI} {HINT}Use --no-verify to skip pre-merge checks{HINT:#}");
+ return Err(GitError::CommandFailed(String::new()));
+ }
+ }
+
+ Ok(())
+}
+
+/// Expand template variables in a command, including {target}
+fn expand_command_template(
+ command: &str,
+ repo_name: &str,
+ branch: &str,
+ target_branch: &str,
+ worktree_path: &std::path::Path,
+ repo_root: &std::path::Path,
+) -> String {
+ let mut extra = HashMap::new();
+ extra.insert("worktree", worktree_path.to_str().unwrap_or(""));
+ extra.insert("repo_root", repo_root.to_str().unwrap_or(""));
+ extra.insert("target", target_branch);
+
+ expand_template(command, repo_name, branch, &extra)
+}
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 8869ed6b7..d217ae47a 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -1,3 +1,4 @@
+pub mod command_approval;
pub mod completion;
pub mod config;
pub mod configure_shell;
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index cd75857f1..2d8c91f24 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -101,7 +101,6 @@
//! See also: DEMO.md for detailed architecture explanation.
use std::collections::HashMap;
-use std::io;
use std::path::PathBuf;
use worktrunk::config::{ProjectConfig, WorktrunkConfig, expand_template};
use worktrunk::git::{GitError, Repository};
@@ -109,6 +108,7 @@ use worktrunk::styling::{
AnstyleStyle, ERROR, ERROR_EMOJI, HINT, HINT_EMOJI, WARNING, WARNING_EMOJI, eprintln, println,
};
+use crate::commands::command_approval::{check_and_approve_command, command_config_to_vec};
use crate::commands::process::spawn_detached;
use crate::output::execute_command_in_worktree;
@@ -360,35 +360,6 @@ fn expand_command_template(
expand_template(command, repo_name, branch, &extra)
}
-/// Prompt the user to approve a command for execution
-fn prompt_for_approval(command: &str, project_id: &str) -> io::Result<bool> {
- use anstyle::Style;
- use std::io::Write;
- use worktrunk::styling::{HINT_EMOJI, eprint};
-
- // Extract project name from project_id (e.g., "worktrunk" from "github.com/max-sixty/worktrunk")
- let project_name = project_id.split('/').next_back().unwrap_or(project_id);
- let bold = Style::new().bold();
- let dim = Style::new().dimmed();
-
- eprintln!();
- eprintln!("{WARNING_EMOJI} {WARNING}Permission required to execute in worktree{WARNING:#}");
- eprintln!();
- eprintln!("{bold}{project_name}{bold:#} ({project_id}) wants to execute:");
- eprintln!();
- eprintln!(" {dim}{command}{dim:#}");
- eprintln!();
- eprint!("{HINT_EMOJI} Allow and remember? {bold}[y/N]{bold:#} ");
- anstream::stderr().flush()?;
-
- let mut input = String::new();
- io::stdin().read_line(&mut input)?;
- eprintln!(); // Move to next line after user input
-
- let response = input.trim().to_lowercase();
- Ok(response == "y" || response == "yes")
-}
-
/// Helper to load project config with error handling
fn load_project_config(repo: &Repository) -> Result<Option<ProjectConfig>, GitError> {
let repo_root = repo.worktree_root()?;
@@ -409,25 +380,6 @@ fn load_project_config(repo: &Repository) -> Result<Option<ProjectConfig>, GitEr
}
}
-/// Convert CommandConfig to a vector of (name, command) pairs
-fn command_config_to_vec(config: &worktrunk::config::CommandConfig) -> Vec<(String, String)> {
- use worktrunk::config::CommandConfig;
- match config {
- CommandConfig::Single(cmd) => vec![("default".to_string(), cmd.clone())],
- CommandConfig::Multiple(cmds) => cmds
- .iter()
- .enumerate()
- .map(|(i, cmd)| (format!("cmd-{}", i), cmd.clone()))
- .collect(),
- CommandConfig::Named(map) => {
- let mut pairs: Vec<_> = map.iter().map(|(k, v)| (k.clone(), v.clone())).collect();
- // Sort by name for deterministic iteration order
- pairs.sort_by(|a, b| a.0.cmp(&b.0));
- pairs
- }
- }
-}
-
/// Execute post-create commands sequentially (blocking)
fn execute_post_create_commands(
worktree_path: &std::path::Path,
@@ -446,7 +398,7 @@ fn execute_post_create_commands(
return Ok(());
};
- let commands = command_config_to_vec(post_create_config);
+ let commands = command_config_to_vec(post_create_config, "cmd");
if commands.is_empty() {
return Ok(());
}
@@ -472,7 +424,10 @@ fn execute_post_create_commands(
let _ = std::io::stderr().flush();
if let Err(e) = execute_command_in_worktree(worktree_path, &expanded_command) {
- eprintln!("{WARNING_EMOJI} {WARNING}Command '{name}' failed: {e}{WARNING:#}");
+ let warning_bold = WARNING.bold();
+ eprintln!(
+ "{WARNING_EMOJI} {WARNING}Command {warning_bold}{name}{warning_bold:#} failed: {e}{WARNING:#}"
+ );
// Continue with other commands even if one fails
}
}
@@ -502,7 +457,7 @@ fn spawn_post_start_commands(
return Ok(());
};
- let commands = command_config_to_vec(post_start_config);
+ let commands = command_config_to_vec(post_start_config, "cmd");
if commands.is_empty() {
return Ok(());
}
@@ -551,48 +506,6 @@ fn spawn_post_start_commands(
Ok(())
}
-/// Check if command is approved and prompt if needed
-fn check_and_approve_command(
- project_id: &str,
- command: &str,
- config: &WorktrunkConfig,
- force: bool,
-) -> Result<bool, GitError> {
- if force || config.is_command_approved(project_id, command) {
- return Ok(true);
- }
-
- match prompt_for_approval(command, project_id) {
- Ok(true) => {
- // Reload config and save approval
- match WorktrunkConfig::load() {
- Ok(mut fresh_config) => {
- if let Err(e) =
- fresh_config.approve_command(project_id.to_string(), command.to_string())
- {
- eprintln!(
- "{WARNING_EMOJI} {WARNING}Failed to save command approval: {e}{WARNING:#}"
- );
- eprintln!("You will be prompted again next time.");
- }
- }
- Err(e) => {
- eprintln!(
- "{WARNING_EMOJI} {WARNING}Failed to reload config for saving approval: {e}{WARNING:#}"
- );
- eprintln!("You will be prompted again next time.");
- }
- }
- Ok(true)
- }
- Ok(false) => Ok(false),
- Err(e) => {
- eprintln!("{WARNING_EMOJI} {WARNING}Failed to read user input: {e}{WARNING:#}");
- Ok(false)
- }
- }
-}
-
pub fn handle_push(target: Option<&str>, allow_merge_commits: bool) -> Result<(), GitError> {
use anstyle::{AnsiColor, Color};
diff --git a/src/config.rs b/src/config.rs
index 2f6a3b6ef..60c15df4b 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -63,17 +63,40 @@ pub struct LlmConfig {
}
/// Project-specific configuration (stored in .config/wt.toml within the project)
+///
+/// # Template Variables
+///
+/// Commands support template variable expansion:
+/// - `{repo}` - Repository name (e.g., "my-project")
+/// - `{branch}` - Branch name (e.g., "feature-foo")
+/// - `{worktree}` - Absolute path to the worktree
+/// - `{repo_root}` - Absolute path to the repository root
+///
+/// Additionally, `pre-merge-check` commands support:
+/// - `{target}` - Target branch for the merge (e.g., "main")
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ProjectConfig {
/// Commands to execute sequentially before worktree is ready (blocking)
/// Supports string (single command), array (sequential), or table (named, sequential)
+ ///
+ /// Available template variables: `{repo}`, `{branch}`, `{worktree}`, `{repo_root}`
#[serde(default, rename = "post-create-command")]
pub post_create_command: Option<CommandConfig>,
/// Commands to execute in parallel as background processes (non-blocking)
/// Supports string (single), array (parallel), or table (named, parallel)
+ ///
+ /// Available template variables: `{repo}`, `{branch}`, `{worktree}`, `{repo_root}`
#[serde(default, rename = "post-start-command")]
pub post_start_command: Option<CommandConfig>,
+
+ /// Commands to execute before merging (blocking, fail-fast validation)
+ /// Supports string (single command), array (sequential), or table (named, sequential)
+ /// All commands must exit with code 0 for merge to proceed
+ ///
+ /// Available template variables: `{repo}`, `{branch}`, `{worktree}`, `{repo_root}`, `{target}`
+ #[serde(default, rename = "pre-merge-check")]
+ pub pre_merge_check: Option<CommandConfig>,
}
/// Configuration for commands - supports multiple formats
@@ -420,6 +443,7 @@ mod tests {
let config = ProjectConfig::default();
assert!(config.post_create_command.is_none());
assert!(config.post_start_command.is_none());
+ assert!(config.pre_merge_check.is_none());
}
#[test]
@@ -477,6 +501,53 @@ mod tests {
assert!(config.post_start_command.is_some());
}
+ #[test]
+ fn test_pre_merge_check_single() {
+ let toml = r#"pre-merge-check = "cargo test""#;
+ let config: ProjectConfig = toml::from_str(toml).unwrap();
+ assert!(matches!(
+ config.pre_merge_check,
+ Some(CommandConfig::Single(_))
+ ));
+ }
+
+ #[test]
+ fn test_pre_merge_check_multiple() {
+ let toml = r#"pre-merge-check = ["cargo fmt -- --check", "cargo test"]"#;
+ let config: ProjectConfig = toml::from_str(toml).unwrap();
+ match config.pre_merge_check {
+ Some(CommandConfig::Multiple(cmds)) => {
+ assert_eq!(cmds.len(), 2);
+ assert_eq!(cmds[0], "cargo fmt -- --check");
+ assert_eq!(cmds[1], "cargo test");
+ }
+ _ => panic!("Expected Multiple variant"),
+ }
+ }
+
+ #[test]
+ fn test_pre_merge_check_named() {
+ let toml = r#"
+ [pre-merge-check]
+ format = "cargo fmt -- --check"
+ lint = "cargo clippy"
+ test = "cargo test"
+ "#;
+ let config: ProjectConfig = toml::from_str(toml).unwrap();
+ match config.pre_merge_check {
+ Some(CommandConfig::Named(cmds)) => {
+ assert_eq!(cmds.len(), 3);
+ assert_eq!(
+ cmds.get("format"),
+ Some(&"cargo fmt -- --check".to_string())
+ );
+ assert_eq!(cmds.get("lint"), Some(&"cargo clippy".to_string()));
+ assert_eq!(cmds.get("test"), Some(&"cargo test".to_string()));
+ }
+ _ => panic!("Expected Named variant"),
+ }
+ }
+
#[test]
fn test_approved_command_equality() {
let cmd1 = ApprovedCommand {
diff --git a/src/main.rs b/src/main.rs
index e633bf43e..f5e2133a4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -151,6 +151,14 @@ enum Commands {
#[arg(short = 'm', long)]
message: Option<String>,
+ /// Skip pre-merge checks
+ #[arg(long)]
+ no_verify: bool,
+
+ /// Skip approval prompts for commands
+ #[arg(short, long)]
+ force: bool,
+
/// Use internal mode (outputs directives for shell wrapper)
#[arg(long, hide = true)]
internal: bool,
@@ -270,12 +278,16 @@ fn main() {
squash,
keep,
message,
+ no_verify,
+ force,
internal,
} => handle_merge(
target.as_deref(),
squash,
keep,
message.as_deref(),
+ no_verify,
+ force,
internal,
),
Commands::Completion { shell } => {
diff --git a/src/styling.rs b/src/styling.rs
index 852e130cd..3965f3ed6 100644
--- a/src/styling.rs
+++ b/src/styling.rs
@@ -42,6 +42,9 @@ pub const ERROR: Style = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Red))
// Message Emojis
// ============================================================================
+/// Progress emoji - use with cyan style: `println!("{PROGRESS_EMOJI} {cyan}message{cyan:#}");`
+pub const PROGRESS_EMOJI: &str = "🔄";
+
/// Error emoji - use with ERROR style: `eprintln!("{ERROR_EMOJI} {ERROR}message{ERROR:#}");`
pub const ERROR_EMOJI: &str = "❌";
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 2c7617a4f..d0780c208 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -373,6 +373,13 @@ pub fn setup_snapshot_settings(repo: &TestRepo) -> insta::Settings {
settings.add_filter(r"\b[0-9a-f]{7,40}\b", "[SHA]");
settings.add_filter(r"\\", "/");
+ // Normalize temp directory paths in project identifiers (approval prompts)
+ // Example: /private/var/folders/wf/.../T/.tmpABC123/origin -> [PROJECT_ID]
+ settings.add_filter(
+ r"/private/var/folders/[^/]+/[^/]+/T/\.[^/]+/[^)]+",
+ "[PROJECT_ID]",
+ );
+
// Normalize timestamps in log filenames (format: YYYYMMDD-HHMMSS)
// The SHA filter runs first, so we match: post-start-NAME-[SHA]-HHMMSS.log
settings.add_filter(
diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rs
index 7559e991a..61c6b2082 100644
--- a/tests/integration_tests/merge.rs
+++ b/tests/integration_tests/merge.rs
@@ -1,5 +1,6 @@
use crate::common::{TestRepo, make_snapshot_cmd, setup_snapshot_settings};
use insta_cmd::assert_cmd_snapshot;
+use std::fs;
use std::process::Command;
/// Helper to create snapshot with normalized paths
@@ -692,3 +693,211 @@ fn test_merge_auto_commit_and_squash() {
],
);
}
+
+#[test]
+fn test_merge_pre_merge_check_success() {
+ let mut repo = TestRepo::new();
+ repo.commit("Initial commit");
+ repo.setup_remote("main");
+
+ // Create project config with pre-merge check
+ let config_dir = repo.root_path().join(".config");
+ fs::create_dir_all(&config_dir).expect("Failed to create config dir");
+ fs::write(config_dir.join("wt.toml"), r#"pre-merge-check = "exit 0""#)
+ .expect("Failed to write config");
+
+ repo.commit("Add config");
+
+ // 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 and make a commit
+ let feature_wt = repo.add_worktree("feature", "feature");
+ fs::write(feature_wt.join("feature.txt"), "feature content").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", "Add feature file"])
+ .current_dir(&feature_wt)
+ .output()
+ .expect("Failed to commit");
+
+ // Merge with --force to skip approval prompts
+ snapshot_merge(
+ "merge_pre_merge_check_success",
+ &repo,
+ &["main", "--force"],
+ Some(&feature_wt),
+ );
+}
+
+#[test]
+fn test_merge_pre_merge_check_failure() {
+ let mut repo = TestRepo::new();
+ repo.commit("Initial commit");
+ repo.setup_remote("main");
+
+ // Create project config with failing pre-merge check
+ let config_dir = repo.root_path().join(".config");
+ fs::create_dir_all(&config_dir).expect("Failed to create config dir");
+ fs::write(config_dir.join("wt.toml"), r#"pre-merge-check = "exit 1""#)
+ .expect("Failed to write config");
+
+ repo.commit("Add config");
+
+ // 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 and make a commit
+ let feature_wt = repo.add_worktree("feature", "feature");
+ fs::write(feature_wt.join("feature.txt"), "feature content").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", "Add feature file"])
+ .current_dir(&feature_wt)
+ .output()
+ .expect("Failed to commit");
+
+ // Merge with --force - pre-merge check should fail and block merge
+ snapshot_merge(
+ "merge_pre_merge_check_failure",
+ &repo,
+ &["main", "--force"],
+ Some(&feature_wt),
+ );
+}
+
+#[test]
+fn test_merge_pre_merge_check_no_verify() {
+ let mut repo = TestRepo::new();
+ repo.commit("Initial commit");
+ repo.setup_remote("main");
+
+ // Create project config with failing pre-merge check
+ let config_dir = repo.root_path().join(".config");
+ fs::create_dir_all(&config_dir).expect("Failed to create config dir");
+ fs::write(config_dir.join("wt.toml"), r#"pre-merge-check = "exit 1""#)
+ .expect("Failed to write config");
+
+ repo.commit("Add config");
+
+ // 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 and make a commit
+ let feature_wt = repo.add_worktree("feature", "feature");
+ fs::write(feature_wt.join("feature.txt"), "feature content").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", "Add feature file"])
+ .current_dir(&feature_wt)
+ .output()
+ .expect("Failed to commit");
+
+ // Merge with --no-verify - should skip pre-merge checks and succeed
+ snapshot_merge(
+ "merge_pre_merge_check_no_verify",
+ &repo,
+ &["main", "--no-verify"],
+ Some(&feature_wt),
+ );
+}
+
+#[test]
+fn test_merge_pre_merge_check_named() {
+ let mut repo = TestRepo::new();
+ repo.commit("Initial commit");
+ repo.setup_remote("main");
+
+ // Create project config with named pre-merge checks
+ let config_dir = repo.root_path().join(".config");
+ fs::create_dir_all(&config_dir).expect("Failed to create config dir");
+ fs::write(
+ config_dir.join("wt.toml"),
+ r#"
+[pre-merge-check]
+format = "exit 0"
+lint = "exit 0"
+test = "exit 0"
+"#,
+ )
+ .expect("Failed to write config");
+
+ repo.commit("Add config");
+
+ // 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 and make a commit
+ let feature_wt = repo.add_worktree("feature", "feature");
+ fs::write(feature_wt.join("feature.txt"), "feature content").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", "Add feature file"])
+ .current_dir(&feature_wt)
+ .output()
+ .expect("Failed to commit");
+
+ // Merge with --force - all pre-merge checks should pass
+ snapshot_merge(
+ "merge_pre_merge_check_named",
+ &repo,
+ &["main", "--force"],
+ Some(&feature_wt),
+ );
+}
diff --git a/tests/snapshots/integration__integration_tests__column_alignment__alignment_empty_diffs.snap b/tests/snapshots/integration__integration_tests__column_alignment__alignment_empty_diffs.snap
deleted file mode 100644
index a1bd0c67b..000000000
--- a/tests/snapshots/integration__integration_tests__column_alignment__alignment_empty_diffs.snap
+++ /dev/null
@@ -1,30 +0,0 @@
----
-source: tests/integration_tests/column_alignment.rs
-info:
- program: wt
- args:
- - list
- env:
- CLICOLOR_FORCE: "1"
- COLUMNS: "180"
- 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: "1704067200"
----
-success: true
-exit_code: 0
------ stdout -----
-Branch  Age  WT +/- Commit  Message  Path
-main  9 months ago b834638e Initial commit ./main
-also-no-changes 9 months ago b834638e Initial commit ./also-no-changes
-no-changes 9 months ago b834638e Initial commit ./no-changes
-with-changes 9 months ago +1 -1 b834638e Initial commit ./with-changes
-
-Showing 4 worktrees, 1 with changes
-
------ stderr -----
diff --git a/tests/snapshots/integration__integration_tests__column_alignment__alignment_extreme_diffs.snap b/tests/snapshots/integration__integration_tests__column_alignment__alignment_extreme_diffs.snap
deleted file mode 100644
index 75b09e022..000000000
--- a/tests/snapshots/integration__integration_tests__column_alignment__alignment_extreme_diffs.snap
+++ /dev/null
@@ -1,29 +0,0 @@
----
-source: tests/integration_tests/column_alignment.rs
-info:
- program: wt
- args:
- - list
- env:
- CLICOLOR_FORCE: "1"
- COLUMNS: "180"
- 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: "1704067200"
----
-success: true
-exit_code: 0
------ stdout -----
-Branch Age  WT +/- Commit  Message  Path
-main  9 months ago b834638e Initial commit ./main
-huge 9 months ago b834638e Initial commit ./huge
-tiny 9 months ago +1 -1 b834638e Initial commit ./tiny
-
-Showing 3 worktrees, 1 with changes
-
------ stderr -----
diff --git a/tests/snapshots/integration__integration_tests__column_alignment__alignment_varying_diffs.snap b/tests/snapshots/integration__integration_tests__column_alignment__alignment_varying_diffs.snap
deleted file mode 100644
index 4007cea90..000000000
--- a/tests/snapshots/integration__integration_tests__column_alignment__alignment_varying_diffs.snap
+++ /dev/null
@@ -1,30 +0,0 @@
----
-source: tests/integration_tests/column_alignment.rs
-info:
- program: wt
- args:
- - list
- env:
- CLICOLOR_FORCE: "1"
- COLUMNS: "180"
- 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: "1704067200"
----
-success: true
-exit_code: 0
------ stdout -----
-Branch  Age  Commit  Message  Path
-main  9 months ago b834638e Initial commit ./main
-feature-large 9 months ago b834638e Initial commit ./feature-large
-feature-medium 9 months ago b834638e Initial commit ./feature-medium
-feature-small 9 months ago b834638e Initial commit ./feature-small
-
-Showing 4 worktrees
-
------ stderr -----
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap
index b10135043..d4c5cdd6b 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap
@@ -307,7 +307,7 @@ _wt() {
return 0
;;
wt__merge)
- opts="-s -k -m -h --squash --keep --message --help [TARGET]"
+ opts="-s -k -m -f -h --squash --keep --message --no-verify --force --help [TARGET]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
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 62b5a8bc7..44a5ad96b 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
@@ -309,7 +309,7 @@ _wt() {
return 0
;;
wt__merge)
- opts="-s -k -m -h --squash --keep --message --help [TARGET]"
+ opts="-s -k -m -f -h --squash --keep --message --no-verify --force --help [TARGET]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snap
index 8d61ff767..69ce31e31 100644
--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap
@@ -180,6 +180,8 @@ 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-verify -d 'Skip pre-merge checks'
+complete -c wt -n "__fish_wt_using_subcommand merge" -s f -l force -d 'Skip approval prompts for commands'
complete -c wt -n "__fish_wt_using_subcommand merge" -s h -l help -d 'Print help'
complete -c wt -n "__fish_wt_using_subcommand completion" -s h -l help -d 'Print help'
complete -c wt -n "__fish_wt_using_subcommand complete" -s h -l help -d 'Print help'
diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
index a877a2d51..7ef6cf154 100644
--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
@@ -229,6 +229,9 @@ _arguments "${_arguments_options[@]}" : \
'--squash[Squash all commits into one before merging]' \
'-k[Keep worktree after merging (don'\''t remove)]' \
'--keep[Keep worktree after merging (don'\''t remove)]' \
+'--no-verify[Skip pre-merge checks]' \
+'-f[Skip approval prompts for commands]' \
+'--force[Skip approval prompts for commands]' \
'-h[Print help]' \
'--help[Print help]' \
'::target -- Target branch to merge into (defaults to default branch):_default' \
diff --git a/tests/snapshots/integration__integration_tests__list__json_multiple_worktrees.snap b/tests/snapshots/integration__integration_tests__list__json_multiple_worktrees.snap
deleted file mode 100644
index 056fb815d..000000000
--- a/tests/snapshots/integration__integration_tests__list__json_multiple_worktrees.snap
+++ /dev/null
@@ -1,112 +0,0 @@
----
-source: tests/integration_tests/list.rs
-info:
- program: wt
- args:
- - list
- - "--format=json"
- env:
- CLICOLOR_FORCE: "1"
- 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: "1704067200"
----
-success: true
-exit_code: 0
------ stdout -----
-[
- {
- "type": "worktree",
- "worktree": {
- "path": "[REPO]",
- "head": "[SHA]",
- "branch": "main",
- "bare": false,
- "detached": false,
- "locked": null,
- "prunable": null
- },
- "timestamp": 0,
- "commit_message": "Initial commit",
- "ahead": 0,
- "behind": 0,
- "working_tree_diff": [
- 0,
- 0
- ],
- "branch_diff": [
- 0,
- 0
- ],
- "is_primary": true,
- "upstream_remote": null,
- "upstream_ahead": 0,
- "upstream_behind": 0,
- "worktree_state": null
- },
- {
- "type": "worktree",
- "worktree": {
- "path": "[WORKTREE_FEATURE_A]",
- "head": "[SHA]",
- "branch": "feature-a",
- "bare": false,
- "detached": false,
- "locked": null,
- "prunable": null
- },
- "timestamp": 0,
- "commit_message": "Initial commit",
- "ahead": 0,
- "behind": 0,
- "working_tree_diff": [
- 0,
- 0
- ],
- "branch_diff": [
- 0,
- 0
- ],
- "is_primary": false,
- "upstream_remote": null,
- "upstream_ahead": 0,
- "upstream_behind": 0,
- "worktree_state": null
- },
- {
- "type": "worktree",
- "worktree": {
- "path": "[WORKTREE_FEATURE_B]",
- "head": "[SHA]",
- "branch": "feature-b",
- "bare": false,
- "detached": false,
- "locked": null,
- "prunable": null
- },
- "timestamp": 0,
- "commit_message": "Initial commit",
- "ahead": 0,
- "behind": 0,
- "working_tree_diff": [
- 0,
- 0
- ],
- "branch_diff": [
- 0,
- 0
- ],
- "is_primary": false,
- "upstream_remote": null,
- "upstream_ahead": 0,
- "upstream_behind": 0,
- "worktree_state": null
- }
-]
-
------ stderr -----
diff --git a/tests/snapshots/integration__integration_tests__list__json_single_worktree.snap b/tests/snapshots/integration__integration_tests__list__json_single_worktree.snap
deleted file mode 100644
index bc2b2d836..000000000
--- a/tests/snapshots/integration__integration_tests__list__json_single_worktree.snap
+++ /dev/null
@@ -1,54 +0,0 @@
----
-source: tests/integration_tests/list.rs
-info:
- program: wt
- args:
- - list
- - "--format=json"
- env:
- CLICOLOR_FORCE: "1"
- 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: "1704067200"
----
-success: true
-exit_code: 0
------ stdout -----
-[
- {
- "type": "worktree",
- "worktree": {
- "path": "[REPO]",
- "head": "[SHA]",
- "branch": "main",
- "bare": false,
- "detached": false,
- "locked": null,
- "prunable": null
- },
- "timestamp": 0,
- "commit_message": "Initial commit",
- "ahead": 0,
- "behind": 0,
- "working_tree_diff": [
- 0,
- 0
- ],
- "branch_diff": [
- 0,
- 0
- ],
- "is_primary": true,
- "upstream_remote": null,
- "upstream_ahead": 0,
- "upstream_behind": 0,
- "worktree_state": null
- }
-]
-
------ stderr -----
diff --git a/tests/snapshots/integration__integration_tests__list__long_branch_name.snap b/tests/snapshots/integration__integration_tests__list__long_branch_name.snap
deleted file mode 100644
index 6adecbed6..000000000
--- a/tests/snapshots/integration__integration_tests__list__long_branch_name.snap
+++ /dev/null
@@ -1,27 +0,0 @@
----
-source: tests/integration_tests/list.rs
-info:
- program: wt
- args:
- - list
- env:
- CLICOLOR_FORCE: "1"
- 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: "1704067200"
----
-success: true
-exit_code: 0
------ stdout -----
-Branch  Commit  Path
-main  b834638e ./main
-feature-this-is-a-very-long-branch-name-that-should-test-column-alignment b834638e ./feature-this-is-a-very-long-branch-name-that-should-test-column-alignment
-
-Showing 2 worktrees
-
------ stderr -----
diff --git a/tests/snapshots/integration__integration_tests__list__unicode_branch_name.snap b/tests/snapshots/integration__integration_tests__list__unicode_branch_name.snap
deleted file mode 100644
index a06757ae7..000000000
--- a/tests/snapshots/integration__integration_tests__list__unicode_branch_name.snap
+++ /dev/null
@@ -1,28 +0,0 @@
----
-source: tests/integration_tests/list.rs
-info:
- program: wt
- args:
- - list
- env:
- CLICOLOR_FORCE: "1"
- 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: "1704067200"
----
-success: true
-exit_code: 0
------ stdout -----
-Branch  Age  Commit  Path
-main  9 months ago b834638e ./main
-feature-日本語-test 9 months ago b834638e ./feature-日本語-test
-fix-émoji-🎉 9 months ago b834638e ./fix-émoji-🎉
-
-Showing 3 worktrees
-
------ stderr -----
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_failure.snap
new file mode 100644
index 000000000..a8def8be7
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_failure.snap
@@ -0,0 +1,31 @@
+---
+source: tests/integration_tests/merge.rs
+info:
+ program: wt
+ args:
+ - merge
+ - main
+ - "--force"
+ env:
+ CLICOLOR_FORCE: "1"
+ 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: "1704067200"
+---
+success: false
+exit_code: 1
+----- stdout -----
+🔄 Running pre-merge check 'cmd'...
+
+----- stderr -----
+
+❌ Pre-merge check failed: cmd
+
+ Command 'exit 1' failed with exit code 1
+
+💡 Use --no-verify to skip pre-merge checks
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_named.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_named.snap
new file mode 100644
index 000000000..d8d3809cf
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_named.snap
@@ -0,0 +1,43 @@
+---
+source: tests/integration_tests/merge.rs
+info:
+ program: wt
+ args:
+ - merge
+ - main
+ - "--force"
+ env:
+ CLICOLOR_FORCE: "1"
+ 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: "1704067200"
+---
+success: true
+exit_code: 0
+----- stdout -----
+🔄 Running pre-merge check 'format'...
+🔄 Running pre-merge check 'lint'...
+🔄 Running pre-merge check 'test'...
+🔄 Rebasing onto main...
+🔄 Pushing 1 commit to main @ [SHA]
+
+* c7fa7c0 (HEAD -> feature) Add feature file
+
+ feature.txt | 1 +
+ 1 file changed, 1 insertion(+)
+
+✅ Pushed to main (1 commit, 1 file, +1) 
+🔄 Cleaning up worktree...
+✅ Removed worktree and returned to primary
+ Path: [REPO]
+
+To enable automatic cd, run: wt configure-shell
+
+✅ Merge complete
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_no_verify.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_no_verify.snap
new file mode 100644
index 000000000..f914636eb
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_no_verify.snap
@@ -0,0 +1,40 @@
+---
+source: tests/integration_tests/merge.rs
+info:
+ program: wt
+ args:
+ - merge
+ - main
+ - "--no-verify"
+ env:
+ CLICOLOR_FORCE: "1"
+ 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: "1704067200"
+---
+success: true
+exit_code: 0
+----- stdout -----
+🔄 Rebasing onto main...
+🔄 Pushing 1 commit to main @ [SHA]
+
+* 1b3bfe2 (HEAD -> feature) Add feature file
+
+ feature.txt | 1 +
+ 1 file changed, 1 insertion(+)
+
+✅ Pushed to main (1 commit, 1 file, +1) 
+🔄 Cleaning up worktree...
+✅ Removed worktree and returned to primary
+ Path: [REPO]
+
+To enable automatic cd, run: wt configure-shell
+
+✅ Merge complete
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_success.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_success.snap
new file mode 100644
index 000000000..967e03a01
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_success.snap
@@ -0,0 +1,41 @@
+---
+source: tests/integration_tests/merge.rs
+info:
+ program: wt
+ args:
+ - merge
+ - main
+ - "--force"
+ env:
+ CLICOLOR_FORCE: "1"
+ 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: "1704067200"
+---
+success: true
+exit_code: 0
+----- stdout -----
+🔄 Running pre-merge check 'cmd'...
+🔄 Rebasing onto main...
+🔄 Pushing 1 commit to main @ [SHA]
+
+* 8c7e1b3 (HEAD -> feature) Add feature file
+
+ feature.txt | 1 +
+ 1 file changed, 1 insertion(+)
+
+✅ Pushed to main (1 commit, 1 file, +1) 
+🔄 Cleaning up worktree...
+✅ Removed worktree and returned to primary
+ Path: [REPO]
+
+To enable automatic cd, run: wt configure-shell
+
+✅ Merge complete
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap
index ceb25038b..76bfe8c87 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap
@@ -13,7 +13,7 @@ info:
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
GIT_EDITOR: ""
- HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpN6uBLs
+ HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpqHEqBw
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1704067200"
@@ -28,4 +28,4 @@ To enable automatic cd, run: wt configure-shell
----- stderr -----
🔄 Executing (post-create): exit 1
-🟡 Command 'default' failed: Command 'exit 1' failed with exit code 1
+🟡 Command cmd failed: Command 'exit 1' failed with exit code 1