Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(config): iterate PowerShell uniformly with other shells (#2581)
Maximilian Roos61046fb108a8
diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rsindex e5a266cfb..374817c31 100644--- a/src/commands/configure_shell.rs+++ b/src/commands/configure_shell.rs@@ -329,19 +329,25 @@ pub fn scan_shell_configs(dry_run: bool,cmd: &str,) -> Result<ScanResult, String> {- // Base shells to check- let mut default_shells = vec![Shell::Bash, Shell::Zsh, Shell::Fish, Shell::Nushell];+ // Iterate every supported shell. Shells the user doesn't have are filtered+ // out of the Skipped output by `is_installed()` below, matching how+ // bash/zsh/fish/nushell are handled.+ let default_shells = vec![+ Shell::Bash,+ Shell::Zsh,+ Shell::Fish,+ Shell::Nushell,+ Shell::PowerShell,+ ];- // Add PowerShell if we detect we're in a PowerShell-compatible environment.- // - Non-Windows: PSModulePath reliably indicates PowerShell Core- // - Windows: SHELL not set indicates Windows-native shell (cmd or PowerShell)+ // Detect whether the user is *running in* PowerShell or Nushell right now.+ // This unlocks `allow_create` so we'll write a profile/autoload file even+ // when none exists — needed because PowerShell users may not have a profile+ // (issue #885) and Nushell's vendor/autoload was introduced in 0.96.0.+ // - PowerShell (non-Windows): PSModulePath set+ // - PowerShell (Windows): SHELL absent (Git Bash/MSYS2/Cygwin set it)+ // - Nushell: `nu` on PATHlet in_powershell_env = should_auto_configure_powershell();- if in_powershell_env {- default_shells.push(Shell::PowerShell);- }-- // Check if nushell is available on the system (nu binary in PATH).- // vendor/autoload/ may not exist yet, but we should still install if nu is available.let nushell_available = Shell::Nushell.is_installed();let shells = shell_filter.map_or(default_shells, |shell| vec![shell]);diff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rsindex bed4f0071..51d894011 100644--- a/tests/integration_tests/configure_shell.rs+++ b/tests/integration_tests/configure_shell.rs@@ -593,7 +593,9 @@ fn test_configure_shell_skipped_lists_only_installed_shells(repo: TestRepo, temp//// Here bash and fish are flagged installed but their rc files don't exist;// they should appear as Skipped. zsh and nu remain "not installed" and- // must not appear at all.+ // must not appear at all. PowerShell coverage lives in+ // `test_powershell_skipped_when_installed_no_profile` (Unix-only because+ // the profile path differs on Windows).let settings = setup_home_snapshot_settings(&temp_home);settings.bind(|| {let mut cmd = wt_command();@@ -621,6 +623,37 @@ fn test_configure_shell_skipped_lists_only_installed_shells(repo: TestRepo, temp});}+/// PowerShell now iterates unconditionally and surfaces in `Skipped` via+/// `is_installed()`, just like bash/zsh/fish/nushell. Unix-only because the+/// profile path differs on Windows (`~/Documents/PowerShell/...`).+#[rstest]+#[cfg(unix)]+fn test_powershell_skipped_when_installed_no_profile(repo: TestRepo, temp_home: TempDir) {+ let settings = setup_home_snapshot_settings(&temp_home);+ settings.bind(|| {+ let mut cmd = wt_command();+ repo.configure_wt_cmd(&mut cmd);+ set_temp_home_env(&mut cmd, temp_home.path());+ cmd.env("SHELL", "/bin/zsh");+ cmd.env("WORKTRUNK_TEST_POWERSHELL_INSTALLED", "1");+ cmd.arg("config")+ .arg("shell")+ .arg("install")+ .arg("--yes")+ .current_dir(repo.root_path());++ assert_cmd_snapshot!(cmd, @"+ success: false+ exit_code: 1+ ----- stdout -----++ ----- stderr -----+ [2m↳[22m [2mSkipped [4mpowershell[24m; [4m~/.config/powershell/Microsoft.PowerShell_profile.ps1[24m not found[22m+ [31m✗[39m [31mNo shell config files found[39m+ ");+ });+}+/// No shells installed and no rc files — clean error, no Skipped lines.////// Pairs with `test_configure_shell_skipped_lists_only_installed_shells`,