Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Feat: Implement project-specific post-start commands
Maximilian Roos8fa7e5239e58
diff --git a/Cargo.toml b/Cargo.tomlindex 39a647ef2..ac60db65d 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -28,6 +28,7 @@ rayon = "1.10"serde = { version = "1.0", features = ["derive"] }serde_json = "1.0"terminal_size = "0.4"+toml = "0.8"unicode-width = "0.2"[build-dependencies]diff --git a/src/commands/worktree.rs b/src/commands/worktree.rsindex 32cc5ebb9..f9946b9c1 100644--- a/src/commands/worktree.rs+++ b/src/commands/worktree.rs@@ -1,5 +1,6 @@+use std::io::{self, Write};use std::path::PathBuf;-use worktrunk::config::WorktrunkConfig;+use worktrunk::config::{ProjectConfig, WorktrunkConfig};use worktrunk::git::{GitError, Repository};use worktrunk::styling::{format_error, format_error_with_bold, format_hint};@@ -184,7 +185,12 @@ pub fn handle_switch(}// Canonicalize the path for cleaner display- let canonical_path = worktree_path.canonicalize().unwrap_or(worktree_path);+ let canonical_path = worktree_path+ .canonicalize()+ .unwrap_or_else(|_| worktree_path.clone());++ // Execute post-start commands from project config+ execute_post_start_commands(&canonical_path, &repo, config)?;Ok(SwitchResult::CreatedWorktree {path: canonical_path,@@ -331,6 +337,143 @@ fn check_worktree_conflicts(Ok(())}+/// Execute a command in the specified worktree directory+fn execute_command_in_worktree(+ worktree_path: &std::path::Path,+ command: &str,+) -> Result<(), GitError> {+ use std::process::Command;++ // Use platform-specific shell+ #[cfg(target_os = "windows")]+ let (shell, shell_arg) = ("cmd", "/C");+ #[cfg(not(target_os = "windows"))]+ let (shell, shell_arg) = ("sh", "-c");++ let output = Command::new(shell)+ .arg(shell_arg)+ .arg(command)+ .current_dir(worktree_path)+ .output()+ .map_err(|e| GitError::CommandFailed(format!("Failed to execute command: {}", e)))?;++ // Forward stdout/stderr to user+ std::io::stdout().write_all(&output.stdout).ok();+ std::io::stderr().write_all(&output.stderr).ok();++ if !output.status.success() {+ return Err(GitError::CommandFailed(format!(+ "Command '{}' exited with status: {}",+ command,+ output.status.code().unwrap_or(-1)+ )));+ }++ Ok(())+}++/// Prompt the user to approve a command for execution+fn prompt_for_approval(command: &str, project_id: &str) -> io::Result<bool> {+ eprintln!();+ eprintln!("⚠️ Project '{}' wants to run a command:", project_id);+ eprintln!();+ eprintln!(" {}", command);+ eprintln!();+ eprintln!("⚠️ WARNING: This will execute with FULL SHELL ACCESS in the new worktree.");+ eprintln!(" The command can read/write files, access network, run arbitrary code.");+ eprintln!();+ eprint!("Approve and remember for this project? [y/N] ");+ io::stderr().flush()?;++ let mut input = String::new();+ io::stdin().read_line(&mut input)?;++ let response = input.trim().to_lowercase();+ Ok(response == "y" || response == "yes")+}++/// Execute post-start commands from project config+fn execute_post_start_commands(+ worktree_path: &std::path::Path,+ repo: &Repository,+ config: &WorktrunkConfig,+) -> Result<(), GitError> {+ // Load project config+ let repo_root = repo.repo_root()?;+ let config_path = repo_root.join(".config").join("wt.toml");+ let project_config = match ProjectConfig::load(&repo_root) {+ Ok(Some(cfg)) => cfg,+ Ok(None) => return Ok(()), // No project config+ Err(e) => {+ eprintln!(+ "Warning: Failed to load project config from {}",+ config_path.display()+ );+ eprintln!("Error: {}", e);+ eprintln!("Skipping post-start commands. Check TOML syntax if file exists.");+ return Ok(());+ }+ };++ if project_config.post_start_commands.is_empty() {+ return Ok(());+ }++ // Get project identifier+ let project_id = repo.project_identifier()?;++ // Execute each command+ for command in &project_config.post_start_commands {+ // Check if command is already approved+ let approved = if config.is_command_approved(&project_id, command) {+ true+ } else {+ // Prompt for approval+ 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.clone(), command.clone())+ {+ eprintln!("Warning: Failed to save command approval: {}", e);+ eprintln!("You will be prompted again next time.");+ }+ }+ Err(e) => {+ eprintln!(+ "Warning: Failed to reload config for saving approval: {}",+ e+ );+ eprintln!("You will be prompted again next time.");+ }+ }+ true+ }+ Ok(false) => {+ eprintln!("Skipping command: {}", command);+ false+ }+ Err(e) => {+ eprintln!("Warning: Failed to read user input: {}", e);+ false+ }+ }+ };++ if approved {+ eprintln!("Executing: {}", command);+ if let Err(e) = execute_command_in_worktree(worktree_path, command) {+ eprintln!("Warning: Command failed: {}", e);+ // Continue with other commands even if one fails+ }+ }+ }++ Ok(())+}+pub fn handle_push(target: Option<&str>, allow_merge_commits: bool) -> Result<(), GitError> {let repo = Repository::current();diff --git a/src/config.rs b/src/config.rsindex e86ca634c..0bf6f61d5 100644--- a/src/config.rs+++ b/src/config.rs@@ -2,6 +2,7 @@ use config::{Config, ConfigError, File};use directories::ProjectDirs;use serde::{Deserialize, Serialize};use std::path::PathBuf;+use toml;/// Configuration for worktree path formatting and LLM integration.///@@ -43,6 +44,10 @@ pub struct WorktrunkConfig {#[serde(default)]pub llm: LlmConfig,++ /// Commands that have been approved for automatic execution+ #[serde(default, rename = "approved-commands")]+ pub approved_commands: Vec<ApprovedCommand>,}/// Configuration for LLM integration@@ -57,11 +62,29 @@ pub struct LlmConfig {pub args: Vec<String>,}+/// Project-specific configuration (stored in .config/wt.toml within the project)+#[derive(Debug, Serialize, Deserialize, Clone, Default)]+pub struct ProjectConfig {+ /// Commands to execute after creating a new worktree+ #[serde(default, rename = "post-start-commands")]+ pub post_start_commands: Vec<String>,+}++/// Approved command for automatic execution+#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]+pub struct ApprovedCommand {+ /// Project identifier (git remote URL or repo name)+ pub project: String,+ /// Command that was approved+ pub command: String,+}+impl Default for WorktrunkConfig {fn default() -> Self {Self {worktree_path: "../{repo}.{branch}".to_string(),llm: LlmConfig::default(),+ approved_commands: Vec::new(),}}}@@ -123,6 +146,65 @@ fn get_config_path() -> Option<PathBuf> {ProjectDirs::from("", "", "worktrunk").map(|dirs| dirs.config_dir().join("config.toml"))}+impl ProjectConfig {+ /// Load project configuration from .config/wt.toml in the repository root+ pub fn load(repo_root: &std::path::Path) -> Result<Option<Self>, ConfigError> {+ let config_path = repo_root.join(".config").join("wt.toml");++ if !config_path.exists() {+ return Ok(None);+ }++ let config = Config::builder()+ .add_source(File::from(config_path))+ .build()?;++ Ok(Some(config.try_deserialize()?))+ }+}++impl WorktrunkConfig {+ /// Check if a command is approved for the given project+ pub fn is_command_approved(&self, project: &str, command: &str) -> bool {+ self.approved_commands+ .iter()+ .any(|ac| ac.project == project && ac.command == command)+ }++ /// Add an approved command and save to config file+ pub fn approve_command(&mut self, project: String, command: String) -> Result<(), ConfigError> {+ // Don't add duplicates+ if self.is_command_approved(&project, &command) {+ return Ok(());+ }++ self.approved_commands+ .push(ApprovedCommand { project, command });+ self.save()+ }++ /// Save the current configuration to the config file+ fn save(&self) -> Result<(), ConfigError> {+ let config_path = get_config_path()+ .ok_or_else(|| ConfigError::Message("Could not determine config path".to_string()))?;++ // Create parent directory if it doesn't exist+ if let Some(parent) = config_path.parent() {+ std::fs::create_dir_all(parent).map_err(|e| {+ ConfigError::Message(format!("Failed to create config directory: {}", e))+ })?;+ }++ let toml_string = toml::to_string_pretty(self)+ .map_err(|e| ConfigError::Message(format!("Failed to serialize config: {}", e)))?;++ std::fs::write(&config_path, toml_string)+ .map_err(|e| ConfigError::Message(format!("Failed to write config file: {}", e)))?;++ Ok(())+ }+}+fn validate_worktree_path(template: &str) -> Result<(), ConfigError> {if template.is_empty() {return Err(ConfigError::Message(@@ -171,6 +253,7 @@ mod tests {let config = WorktrunkConfig {worktree_path: "{repo}.{branch}".to_string(),llm: LlmConfig::default(),+ approved_commands: Vec::new(),};assert_eq!(config.format_path("myproject", "feature-x"),@@ -183,6 +266,7 @@ mod tests {let config = WorktrunkConfig {worktree_path: "{repo}-{branch}".to_string(),llm: LlmConfig::default(),+ approved_commands: Vec::new(),};assert_eq!(config.format_path("myproject", "feature-x"),@@ -195,6 +279,7 @@ mod tests {let config = WorktrunkConfig {worktree_path: "{branch}".to_string(),llm: LlmConfig::default(),+ approved_commands: Vec::new(),};assert_eq!(config.format_path("myproject", "feature-x"), "feature-x");}@@ -205,6 +290,7 @@ mod tests {let config = WorktrunkConfig {worktree_path: "{repo}.{branch}".to_string(),llm: LlmConfig::default(),+ approved_commands: Vec::new(),};assert_eq!(config.format_path("myproject", "feature/foo"),@@ -217,6 +303,7 @@ mod tests {let config = WorktrunkConfig {worktree_path: "{branch}".to_string(),llm: LlmConfig::default(),+ approved_commands: Vec::new(),};assert_eq!(config.format_path("myproject", "feature/sub/task"),@@ -230,6 +317,7 @@ mod tests {let config = WorktrunkConfig {worktree_path: "{branch}".to_string(),llm: LlmConfig::default(),+ approved_commands: Vec::new(),};assert_eq!(config.format_path("myproject", "feature\\foo"),@@ -265,4 +353,88 @@ mod tests {assert!(validate_worktree_path("../{repo}.{branch}").is_ok());assert!(validate_worktree_path("../../shared/{branch}").is_ok());}++ #[test]+ fn test_project_config_default() {+ let config = ProjectConfig::default();+ assert!(config.post_start_commands.is_empty());+ }++ #[test]+ fn test_project_config_serialization() {+ let config = ProjectConfig {+ post_start_commands: vec!["npm install".to_string(), "npm test".to_string()],+ };+ let toml = toml::to_string(&config).unwrap();+ assert!(toml.contains("post-start-commands"));+ assert!(toml.contains("npm install"));+ assert!(toml.contains("npm test"));+ }++ #[test]+ fn test_project_config_deserialization() {+ let toml = r#"+ post-start-commands = ["npm install", "npm test"]+ "#;+ let config: ProjectConfig = toml::from_str(toml).unwrap();+ assert_eq!(config.post_start_commands.len(), 2);+ assert_eq!(config.post_start_commands[0], "npm install");+ assert_eq!(config.post_start_commands[1], "npm test");+ }++ #[test]+ fn test_approved_command_equality() {+ let cmd1 = ApprovedCommand {+ project: "github.com/user/repo".to_string(),+ command: "npm install".to_string(),+ };+ let cmd2 = ApprovedCommand {+ project: "github.com/user/repo".to_string(),+ command: "npm install".to_string(),+ };+ let cmd3 = ApprovedCommand {+ project: "github.com/user/repo".to_string(),+ command: "npm test".to_string(),+ };+ assert_eq!(cmd1, cmd2);+ assert_ne!(cmd1, cmd3);+ }++ #[test]+ fn test_is_command_approved() {+ let mut config = WorktrunkConfig::default();+ config.approved_commands.push(ApprovedCommand {+ project: "github.com/user/repo".to_string(),+ command: "npm install".to_string(),+ });++ assert!(config.is_command_approved("github.com/user/repo", "npm install"));+ assert!(!config.is_command_approved("github.com/user/repo", "npm test"));+ assert!(!config.is_command_approved("github.com/other/repo", "npm install"));+ }++ #[test]+ fn test_approve_command() {+ let mut config = WorktrunkConfig::default();++ // First approval+ assert!(!config.is_command_approved("github.com/user/repo", "npm install"));+ config+ .approve_command(+ "github.com/user/repo".to_string(),+ "npm install".to_string(),+ )+ .ok(); // Ignore save errors in tests+ assert!(config.is_command_approved("github.com/user/repo", "npm install"));++ // Duplicate approval shouldn't add twice+ let count_before = config.approved_commands.len();+ config+ .approve_command(+ "github.com/user/repo".to_string(),+ "npm install".to_string(),+ )+ .ok();+ assert_eq!(config.approved_commands.len(), count_before);+ }}diff --git a/src/git.rs b/src/git.rsindex a5ea6ea05..61064f696 100644--- a/src/git.rs+++ b/src/git.rs@@ -437,6 +437,71 @@ impl Repository {Ok(())}+ /// Get a project identifier for approval tracking.+ ///+ /// Uses the git remote URL if available (e.g., "github.com/user/repo"),+ /// otherwise falls back to the repository directory name.+ ///+ /// This identifier is used to track which commands have been approved+ /// for execution in this project.+ pub fn project_identifier(&self) -> Result<String, GitError> {+ // Try to get the remote URL first+ let remote = self.primary_remote()?;++ if let Ok(url) = self.run_command(&["remote", "get-url", &remote]) {+ let url = url.trim();++ // Parse common git URL formats:+ // - https://github.com/user/repo.git+ // - [email protected]:user/repo.git+ // - ssh://[email protected]/user/repo.git++ // Remove .git suffix if present+ let url = url.strip_suffix(".git").unwrap_or(url);++ // Handle SSH format (git@host:path)+ if let Some(ssh_part) = url.strip_prefix("git@")+ && let Some((host, path)) = ssh_part.split_once(':')+ {+ return Ok(format!("{}/{}", host, path));+ }++ // Handle HTTPS/HTTP format+ if let Some(https_part) = url+ .strip_prefix("https://")+ .or_else(|| url.strip_prefix("http://"))+ {+ return Ok(https_part.to_string());+ }++ // Handle ssh:// format+ if let Some(ssh_part) = url.strip_prefix("ssh://") {+ // Remove git@ prefix if present+ let ssh_part = ssh_part.strip_prefix("git@").unwrap_or(ssh_part);+ // Replace first : with /+ if let Some(colon_pos) = ssh_part.find(':') {+ let (host, path) = ssh_part.split_at(colon_pos);+ return Ok(format!("{}{}", host, path.replacen(':', "/", 1)));+ }+ return Ok(ssh_part.to_string());+ }++ // If we can't parse it, use the URL as-is+ return Ok(url.to_string());+ }++ // Fall back to repository name+ let repo_root = self.repo_root()?;+ let repo_name = repo_root+ .file_name()+ .and_then(|name| name.to_str())+ .ok_or_else(|| {+ GitError::CommandFailed("Could not determine repository name".to_string())+ })?;++ Ok(repo_name.to_string())+ }+/// Run a git command in this repository's context.////// Executes the git command with this repository's path as the working directory@@ -853,4 +918,13 @@ abcd1234567890abcd1234567890abcd12345678\tHEAD// Test that worktree_for_branch returns None when no worktree exists// This would require a git repo, so we'll test this in integration tests}++ #[test]+ fn test_project_identifier_parsing() {+ // Test URL parsing logic (can't test actual git commands without a repo)+ // These would be unit tests if we extracted the URL parsing logic++ // The actual parsing is done inline in project_identifier(),+ // so we'll rely on integration tests for full coverage+ }}diff --git a/tests/integration_tests/mod.rs b/tests/integration_tests/mod.rsindex e2b7a8a50..a1dc61ae0 100644--- a/tests/integration_tests/mod.rs+++ b/tests/integration_tests/mod.rs@@ -7,6 +7,7 @@ pub mod e2e_shell;pub mod init;pub mod list;pub mod merge;+pub mod post_start_commands;pub mod push;pub mod remove;pub mod spacing_edge_cases;diff --git a/tests/integration_tests/post_start_commands.rs b/tests/integration_tests/post_start_commands.rsnew file mode 100644index 000000000..22d164e13--- /dev/null+++ b/tests/integration_tests/post_start_commands.rs@@ -0,0 +1,187 @@+use crate::common::{TestRepo, make_snapshot_cmd, setup_snapshot_settings};+use insta_cmd::assert_cmd_snapshot;+use std::fs;++/// Helper to create snapshot with normalized paths and SHAs+fn snapshot_switch(test_name: &str, repo: &TestRepo, args: &[&str]) {+ let settings = setup_snapshot_settings(repo);+ settings.bind(|| {+ let mut cmd = make_snapshot_cmd(repo, "switch", args, None);+ assert_cmd_snapshot!(test_name, cmd);+ });+}++#[test]+fn test_post_start_commands_no_config() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Switch without project config should work normally+ snapshot_switch("post_start_no_config", &repo, &["--create", "feature"]);+}++#[test]+fn test_post_start_commands_empty_array() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create empty project config+ 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"), "post-start-commands = []\n")+ .expect("Failed to write config");++ repo.commit("Add empty config");++ // Should work without prompting+ snapshot_switch("post_start_empty_array", &repo, &["--create", "feature"]);+}++#[test]+fn test_post_start_commands_with_approval() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create project config with a simple command+ 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#"post-start-commands = ["echo 'Setup complete'"]"#,+ )+ .expect("Failed to write config");++ repo.commit("Add config");++ // Pre-approve the command by setting up the user config+ // This simulates the command being already approved+ let home_dir = std::env::var("HOME").unwrap();+ let user_config_dir =+ std::path::Path::new(&home_dir).join("Library/Application Support/worktrunk");+ fs::create_dir_all(&user_config_dir).ok();+ fs::write(+ user_config_dir.join("config.toml"),+ format!(+ r#"worktree-path = "../{{repo}}.{{branch}}"++[[approved-commands]]+project = "{}"+command = "echo 'Setup complete'"+"#,+ repo.root_path().file_name().unwrap().to_str().unwrap()+ ),+ )+ .ok();++ // Command should execute without prompting+ snapshot_switch("post_start_with_approval", &repo, &["--create", "feature"]);+}++#[test]+fn test_post_start_commands_invalid_toml() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create invalid TOML+ 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"),+ "post-start-commands = [invalid syntax\n",+ )+ .expect("Failed to write config");++ repo.commit("Add invalid config");++ // Should continue without executing commands, showing warning+ snapshot_switch("post_start_invalid_toml", &repo, &["--create", "feature"]);+}++#[test]+fn test_post_start_commands_failing_command() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create project config with a command that will fail+ 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#"post-start-commands = ["exit 1"]"#,+ )+ .expect("Failed to write config");++ repo.commit("Add config with failing command");++ // Pre-approve the command+ let home_dir = std::env::var("HOME").unwrap();+ let config_dir = std::path::Path::new(&home_dir).join("Library/Application Support/worktrunk");+ fs::create_dir_all(&config_dir).ok();+ fs::write(+ config_dir.join("config.toml"),+ format!(+ r#"worktree-path = "../{{repo}}.{{branch}}"++[[approved-commands]]+project = "{}"+command = "exit 1"+"#,+ repo.root_path().file_name().unwrap().to_str().unwrap()+ ),+ )+ .ok();++ // Should show warning but continue (worktree should still be created)+ snapshot_switch(+ "post_start_failing_command",+ &repo,+ &["--create", "feature"],+ );+}++#[test]+fn test_post_start_commands_multiple_commands() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create project config with multiple commands+ 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#"post-start-commands = ["echo 'First'", "echo 'Second'"]"#,+ )+ .expect("Failed to write config");++ repo.commit("Add config with multiple commands");++ // Pre-approve both commands+ let home_dir = std::env::var("HOME").unwrap();+ let config_dir = std::path::Path::new(&home_dir).join("Library/Application Support/worktrunk");+ fs::create_dir_all(&config_dir).ok();+ fs::write(+ config_dir.join("config.toml"),+ format!(+ r#"worktree-path = "../{{repo}}.{{branch}}"++[[approved-commands]]+project = "{}"+command = "echo 'First'"++[[approved-commands]]+project = "{}"+command = "echo 'Second'"+"#,+ repo.root_path().file_name().unwrap().to_str().unwrap(),+ repo.root_path().file_name().unwrap().to_str().unwrap()+ ),+ )+ .ok();++ // Both commands should execute+ snapshot_switch(+ "post_start_multiple_commands",+ &repo,+ &["--create", "feature"],+ );+}diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_empty_array.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_empty_array.snapnew file mode 100644index 000000000..28c9da6b8--- /dev/null+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_empty_array.snap@@ -0,0 +1,26 @@+---+source: tests/integration_tests/post_start_commands.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ 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 -----+Created new branch and worktree for 'feature' at [REPO].feature+Note: Use 'wt switch' (with shell integration) for automatic cd++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_failing_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_failing_command.snapnew file mode 100644index 000000000..f78dbb72e--- /dev/null+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_failing_command.snap@@ -0,0 +1,28 @@+---+source: tests/integration_tests/post_start_commands.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ 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 -----+Created new branch and worktree for 'feature' at [REPO].feature+Note: Use 'wt switch' (with shell integration) for automatic cd++----- stderr -----+Executing: exit 1+Warning: Command failed: Command 'exit 1' exited with status: 1diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_toml.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_toml.snapnew file mode 100644index 000000000..7c45814f1--- /dev/null+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_toml.snap@@ -0,0 +1,34 @@+---+source: tests/integration_tests/post_start_commands.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ 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 -----+Created new branch and worktree for 'feature' at [REPO].feature+Note: Use 'wt switch' (with shell integration) for automatic cd++----- stderr -----+Warning: Failed to load project config from [REPO]/.config/wt.toml+Error: TOML parse error at line 1, column 39+ |+1 | post-start-commands = [invalid syntax+ | ^+unclosed array, expected `]`+ in .config/wt.toml+Skipping post-start commands. Check TOML syntax if file exists.diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_commands.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_commands.snapnew file mode 100644index 000000000..d21015d5d--- /dev/null+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_commands.snap@@ -0,0 +1,30 @@+---+source: tests/integration_tests/post_start_commands.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ 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 -----+First+Second+Created new branch and worktree for 'feature' at [REPO].feature+Note: Use 'wt switch' (with shell integration) for automatic cd++----- stderr -----+Executing: echo 'First'+Executing: echo 'Second'diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_no_config.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_no_config.snapnew file mode 100644index 000000000..28c9da6b8--- /dev/null+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_no_config.snap@@ -0,0 +1,26 @@+---+source: tests/integration_tests/post_start_commands.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ 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 -----+Created new branch and worktree for 'feature' at [REPO].feature+Note: Use 'wt switch' (with shell integration) for automatic cd++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_with_approval.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_with_approval.snapnew file mode 100644index 000000000..5269a22d3--- /dev/null+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_with_approval.snap@@ -0,0 +1,28 @@+---+source: tests/integration_tests/post_start_commands.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ 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 -----+Setup complete+Created new branch and worktree for 'feature' at [REPO].feature+Note: Use 'wt switch' (with shell integration) for automatic cd++----- stderr -----+Executing: echo 'Setup complete'