Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
docs: document MSYS2 auto path conversion for Windows (#364)
Maximilian Roos9580f173b7a7
diff --git a/.claude/rules/output-system-architecture.md b/.claude/rules/output-system-architecture.mdindex 82d3d7935..4affe055a 100644--- a/.claude/rules/output-system-architecture.md+++ b/.claude/rules/output-system-architecture.md@@ -73,6 +73,23 @@ Examples:(via `shell_exec::run()`). This prevents hooks from writing to the directivefile.+## Windows Compatibility (Git Bash / MSYS2)++On Windows with Git Bash, `mktemp` returns POSIX-style paths like `/tmp/tmp.xxx`.+The native Windows binary (`wt.exe`) needs a Windows path to write to the+directive file.++**No explicit path conversion is needed.** MSYS2 (which Git Bash uses)+automatically converts POSIX paths in environment variables when spawning native+Windows binaries. When the shell wrapper sets `WORKTRUNK_DIRECTIVE_FILE=/tmp/...`+and runs `wt.exe`, MSYS2 translates this to `C:\Users\...\Temp\...` before the+binary sees it.++See: https://www.msys2.org/docs/filesystem-paths/++This means the shell wrapper templates can use `$directive_file` directly without+calling `cygpath -w`. The conversion happens automatically in the MSYS2 runtime.+## Simplification NotesThe output system was originally more complex to handle shell integrationdiff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rsindex cdf9fd5fd..f235bb59b 100644--- a/tests/integration_tests/shell_wrapper.rs+++ b/tests/integration_tests/shell_wrapper.rs@@ -622,29 +622,10 @@ fn exec_through_wrapper_with_env() -> ShellOutput {let script = build_shell_script(shell, repo, subcommand, args);- // Keep config path as owned String because:- // 1. repo.test_config_path() returns a PathBuf- // 2. .to_string_lossy() returns a Cow<str> that borrows from the PathBuf- // 3. We need to borrow a &str for the env_vars vector- // 4. The owned String lives long enough to satisfy the borrow in env_varslet config_path = repo.test_config_path().to_string_lossy().to_string();- // Same environment setup as exec_through_wrapper_from- let mut env_vars: Vec<(&str, &str)> = vec![- ("CLICOLOR_FORCE", "1"),- ("WORKTRUNK_CONFIG_PATH", &config_path),- ("TERM", "xterm"),- ("GIT_AUTHOR_NAME", "Test User"),- ("GIT_AUTHOR_EMAIL", "[email protected]"),- ("GIT_COMMITTER_NAME", "Test User"),- ("GIT_COMMITTER_EMAIL", "[email protected]"),- ("GIT_AUTHOR_DATE", "2025-01-01T00:00:00Z"),- ("GIT_COMMITTER_DATE", "2025-01-01T00:00:00Z"),- ("LANG", "C"),- ("LC_ALL", "C"),- ("SOURCE_DATE_EPOCH", "1735776000"),- ];-+ let mut env_vars = build_test_env_vars(&config_path);+ env_vars.push(("CLICOLOR_FORCE", "1"));// Add extra env vars (these can override defaults if needed)env_vars.extend(extra_env.iter().copied());@@ -657,6 +638,34 @@ fn exec_through_wrapper_with_env(}}+/// Standard test environment variables (static parts that don't depend on test state)+///+/// These are used by tests that build custom scripts and call `exec_in_pty_interactive` directly.+/// For tests using `exec_through_wrapper*`, these are already applied.+const STANDARD_TEST_ENV: &[(&str, &str)] = &[+ ("TERM", "xterm"),+ ("GIT_AUTHOR_NAME", "Test User"),+ ("GIT_AUTHOR_EMAIL", "[email protected]"),+ ("GIT_COMMITTER_NAME", "Test User"),+ ("GIT_COMMITTER_EMAIL", "[email protected]"),+ ("GIT_AUTHOR_DATE", "2025-01-01T00:00:00Z"),+ ("GIT_COMMITTER_DATE", "2025-01-01T00:00:00Z"),+ ("LANG", "C"),+ ("LC_ALL", "C"),+ ("SOURCE_DATE_EPOCH", "1735776000"),+];++/// Build standard test env vars with config path+///+/// Returns a Vec containing STANDARD_TEST_ENV plus WORKTRUNK_CONFIG_PATH.+/// The caller must keep `config_path` alive for the duration of the returned Vec's use.+#[cfg(test)]+fn build_test_env_vars(config_path: &str) -> Vec<(&str, &str)> {+ let mut env_vars: Vec<(&str, &str)> = vec![("WORKTRUNK_CONFIG_PATH", config_path)];+ env_vars.extend_from_slice(STANDARD_TEST_ENV);+ env_vars+}+mod tests {use super::*;use crate::common::repo;@@ -1954,14 +1963,7 @@ approved-commands = ["echo 'bash background'"]};let config_path = repo.test_config_path().to_string_lossy().to_string();- let env_vars: Vec<(&str, &str)> = vec![- ("WORKTRUNK_CONFIG_PATH", &config_path),- ("TERM", "xterm"),- ("GIT_AUTHOR_NAME", "Test User"),- ("GIT_AUTHOR_EMAIL", "[email protected]"),- ("GIT_COMMITTER_NAME", "Test User"),- ("GIT_COMMITTER_EMAIL", "[email protected]"),- ];+ let env_vars = build_test_env_vars(&config_path);let (combined, exit_code) =exec_in_pty_interactive(shell, &final_script, repo.root_path(), &env_vars, &[]);diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snapindex 5a56c4681..db72f4580 100644--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap@@ -25,6 +25,7 @@ info:SOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: truediff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snapindex 29af410db..bb539d5bd 100644--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap@@ -25,6 +25,7 @@ info:SOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: truediff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snapindex be0a9353f..0bbac00b7 100644--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap@@ -25,6 +25,7 @@ info:SOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: true