Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Refactor git command execution into a helper function
Maximilian Roos4d6d39890fa5
diff --git a/src/git.rs b/src/git.rsindex 465dfd1cd..758bd658e 100644--- a/src/git.rs+++ b/src/git.rs@@ -29,9 +29,16 @@ impl std::fmt::Display for GitError {impl std::error::Error for GitError {}-pub fn list_worktrees() -> Result<Vec<Worktree>, GitError> {- let output = Command::new("git")- .args(["worktree", "list", "--porcelain"])+/// Helper function to run a git command and return its stdout+fn run_git_command(args: &[&str], path: Option<&std::path::Path>) -> Result<String, GitError> {+ let mut cmd = Command::new("git");+ cmd.args(args);++ if let Some(p) = path {+ cmd.current_dir(p);+ }++ let output = cmd.output().map_err(|e| GitError::CommandFailed(e.to_string()))?;@@ -40,7 +47,11 @@ pub fn list_worktrees() -> Result<Vec<Worktree>, GitError> {return Err(GitError::CommandFailed(stderr.to_string()));}- let stdout = String::from_utf8_lossy(&output.stdout);+ Ok(String::from_utf8_lossy(&output.stdout).to_string())+}++pub fn list_worktrees() -> Result<Vec<Worktree>, GitError> {+ let stdout = run_git_command(&["worktree", "list", "--porcelain"], None)?;parse_worktree_list(&stdout)}@@ -149,18 +160,7 @@ pub fn get_default_branch_in(path: &std::path::Path) -> Result<String, GitError>/// Try to get the default branch from the local cache (origin/HEAD)fn get_local_default_branch(path: &std::path::Path) -> Result<String, GitError> {- let output = Command::new("git")- .args(["rev-parse", "--abbrev-ref", "origin/HEAD"])- .current_dir(path)- .output()- .map_err(|e| GitError::CommandFailed(e.to_string()))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- return Err(GitError::CommandFailed(stderr.to_string()));- }-- let stdout = String::from_utf8_lossy(&output.stdout);+ let stdout = run_git_command(&["rev-parse", "--abbrev-ref", "origin/HEAD"], Some(path))?;parse_local_default_branch(&stdout)}@@ -185,18 +185,7 @@ fn parse_local_default_branch(output: &str) -> Result<String, GitError> {/// Query the remote to determine the default branchfn query_remote_default_branch(path: &std::path::Path) -> Result<String, GitError> {- let output = Command::new("git")- .args(["ls-remote", "--symref", "origin", "HEAD"])- .current_dir(path)- .output()- .map_err(|e| GitError::CommandFailed(e.to_string()))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- return Err(GitError::CommandFailed(stderr.to_string()));- }-- let stdout = String::from_utf8_lossy(&output.stdout);+ let stdout = run_git_command(&["ls-remote", "--symref", "origin", "HEAD"], Some(path))?;parse_remote_default_branch(&stdout)}@@ -227,17 +216,7 @@ fn parse_remote_default_branch(output: &str) -> Result<String, GitError> {/// Cache the default branch locally by setting origin/HEADfn cache_default_branch(path: &std::path::Path, branch: &str) -> Result<(), GitError> {- let output = Command::new("git")- .args(["remote", "set-head", "origin", branch])- .current_dir(path)- .output()- .map_err(|e| GitError::CommandFailed(e.to_string()))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- return Err(GitError::CommandFailed(stderr.to_string()));- }-+ run_git_command(&["remote", "set-head", "origin", branch], Some(path))?;Ok(())}diff --git a/tests/integration.rs b/tests/integration.rsnew file mode 100644index 000000000..1b52936da--- /dev/null+++ b/tests/integration.rs@@ -0,0 +1,2 @@+mod common;+mod integration_tests;diff --git a/tests/test_default_branch.rs b/tests/integration_tests/default_branch.rssimilarity index 58%rename from tests/test_default_branch.rsrename to tests/integration_tests/default_branch.rsindex 80f842753..28897f9b3 100644--- a/tests/test_default_branch.rs+++ b/tests/integration_tests/default_branch.rs@@ -1,9 +1,7 @@-mod common;--use common::TestRepo;+use crate::common::TestRepo;#[test]-fn test_get_default_branch_with_origin_head_main() {+fn test_get_default_branch_with_origin_head() {let mut repo = TestRepo::new();repo.commit("Initial commit");repo.setup_remote("main");@@ -17,40 +15,6 @@ fn test_get_default_branch_with_origin_head_main() {assert_eq!(branch, "main");}-#[test]-fn test_get_default_branch_with_origin_head_master() {- // Note: TestRepo::new() creates a repo with "main" branch by default,- // but we can still test by setting up the remote with "main" as the actual branch- // and just rename the local branch to "master" first- let mut repo = TestRepo::new();- repo.commit("Initial commit");-- // For this test, we'll just use "main" as the default branch since that's what- // the repo was initialized with. The important thing is testing the detection logic.- // If we want to test with "master", we'd need to rename the branch first.- repo.setup_remote("main");-- assert!(repo.has_origin_head());-- let branch = arbor::git::get_default_branch_in(&repo.root_path())- .expect("Failed to get default branch");- assert_eq!(branch, "main");-}--#[test]-fn test_get_default_branch_with_origin_head_custom() {- // Similar to above - testing with "main" since that's what the repo has- let mut repo = TestRepo::new();- repo.commit("Initial commit");- repo.setup_remote("main");-- assert!(repo.has_origin_head());-- let branch = arbor::git::get_default_branch_in(&repo.root_path())- .expect("Failed to get default branch");- assert_eq!(branch, "main");-}-#[test]fn test_get_default_branch_without_origin_head() {let mut repo = TestRepo::new();diff --git a/tests/test_directives.rs b/tests/integration_tests/directives.rssimilarity index 98%rename from tests/test_directives.rsrename to tests/integration_tests/directives.rsindex 53e408f85..8d7711a1b 100644--- a/tests/test_directives.rs+++ b/tests/integration_tests/directives.rs@@ -1,6 +1,4 @@-mod common;--use common::TestRepo;+use crate::common::TestRepo;use insta::Settings;use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};use std::process::Command;diff --git a/tests/test_init.rs b/tests/integration_tests/init.rssimilarity index 98%rename from tests/test_init.rsrename to tests/integration_tests/init.rsindex 4251d407b..3a74f51d4 100644--- a/tests/test_init.rs+++ b/tests/integration_tests/init.rs@@ -1,6 +1,4 @@-mod common;--use common::TestRepo;+use crate::common::TestRepo;use insta::Settings;use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};use std::process::Command;diff --git a/tests/test_list.rs b/tests/integration_tests/list.rssimilarity index 98%rename from tests/test_list.rsrename to tests/integration_tests/list.rsindex 2c96d7b86..9052a8383 100644--- a/tests/test_list.rs+++ b/tests/integration_tests/list.rs@@ -1,6 +1,4 @@-mod common;--use common::TestRepo;+use crate::common::TestRepo;use insta::Settings;use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};use std::process::Command;diff --git a/tests/integration_tests/mod.rs b/tests/integration_tests/mod.rsnew file mode 100644index 000000000..632d5794f--- /dev/null+++ b/tests/integration_tests/mod.rs@@ -0,0 +1,4 @@+pub mod default_branch;+pub mod directives;+pub mod init;+pub mod list;diff --git a/tests/snapshots/integration__integration_tests__directives__finish_internal_directive.snap b/tests/snapshots/integration__integration_tests__directives__finish_internal_directive.snapnew file mode 100644index 000000000..73211ba2d--- /dev/null+++ b/tests/snapshots/integration__integration_tests__directives__finish_internal_directive.snap@@ -0,0 +1,24 @@+---+source: tests/integration_tests/directives.rs+info:+ program: arbor+ args:+ - finish+ - "--internal"+ env:+ 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 -----+__ARBOR_CD__[PATH]+Finished worktree and returned to primary++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__directives__finish_without_internal.snap b/tests/snapshots/integration__integration_tests__directives__finish_without_internal.snapnew file mode 100644index 000000000..4951d1e59--- /dev/null+++ b/tests/snapshots/integration__integration_tests__directives__finish_without_internal.snap@@ -0,0 +1,23 @@+---+source: tests/integration_tests/directives.rs+info:+ program: arbor+ args:+ - finish+ env:+ 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 -----+Finishing worktree+Note: Use 'arbor-finish' (with shell integration) for automatic cd++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__directives__switch_internal_directive.snap b/tests/snapshots/integration__integration_tests__directives__switch_internal_directive.snapnew file mode 100644index 000000000..356b7d74d--- /dev/null+++ b/tests/snapshots/integration__integration_tests__directives__switch_internal_directive.snap@@ -0,0 +1,25 @@+---+source: tests/integration_tests/directives.rs+info:+ program: arbor+ args:+ - switch+ - my-feature+ - "--internal"+ env:+ 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 -----+__ARBOR_CD__[PATH]+Switched to worktree: my-feature++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__directives__switch_without_internal.snap b/tests/snapshots/integration__integration_tests__directives__switch_without_internal.snapnew file mode 100644index 000000000..fc294d7cd--- /dev/null+++ b/tests/snapshots/integration__integration_tests__directives__switch_without_internal.snap@@ -0,0 +1,24 @@+---+source: tests/integration_tests/directives.rs+info:+ program: arbor+ args:+ - switch+ - my-feature+ env:+ 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 -----+Switching to worktree: my-feature+Note: Use 'arbor-switch' (with shell integration) for automatic cd++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snapnew file mode 100644index 000000000..ec5b8d5af--- /dev/null+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap@@ -0,0 +1,58 @@+---+source: tests/integration_tests/init.rs+info:+ program: arbor+ args:+ - init+ - bash+ env:+ 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 -----+# arbor shell integration for bash++# Helper function to parse arbor output and handle directives+_arbor_exec() {+ local output line exit_code+ output="$("arbor" "$@" 2>&1)"+ exit_code=$?++ # Parse output line by line+ while IFS= read -r line; do+ if [[ "$line" == __ARBOR_CD__* ]]; then+ # Extract path and change directory+ \cd "${line#__ARBOR_CD__}"+ else+ # Regular output - print it+ echo "$line"+ fi+ done <<< "$output"++ return $exit_code+}++# Main commands that support directory changes+arbor-switch() {+ _arbor_exec switch --internal "$@"+}++arbor-finish() {+ _arbor_exec finish --internal "$@"+}++# Convenience aliases+alias arbor-sw='arbor-switch'+alias arbor-fin='arbor-finish'++++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_bash_all_options.snap b/tests/snapshots/integration__integration_tests__init__init_bash_all_options.snapnew file mode 100644index 000000000..d3186835c--- /dev/null+++ b/tests/snapshots/integration__integration_tests__init__init_bash_all_options.snap@@ -0,0 +1,75 @@+---+source: tests/integration_tests/init.rs+info:+ program: arbor+ args:+ - init+ - bash+ - "--cmd"+ - wt+ - "--hook"+ - prompt+ env:+ 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 -----+# arbor shell integration for bash++# Helper function to parse arbor output and handle directives+_arbor_exec() {+ local output line exit_code+ output="$("arbor" "$@" 2>&1)"+ exit_code=$?++ # Parse output line by line+ while IFS= read -r line; do+ if [[ "$line" == __ARBOR_CD__* ]]; then+ # Extract path and change directory+ \cd "${line#__ARBOR_CD__}"+ else+ # Regular output - print it+ echo "$line"+ fi+ done <<< "$output"++ return $exit_code+}++# Main commands that support directory changes+wt-switch() {+ _arbor_exec switch --internal "$@"+}++wt-finish() {+ _arbor_exec finish --internal "$@"+}++# Convenience aliases+alias wt-sw='wt-switch'+alias wt-fin='wt-finish'+++# Prompt hook for tracking current worktree+_arbor_prompt_hook() {+ # Call arbor to update tracking+ command arbor hook prompt 2>/dev/null || true+}++# Add to PROMPT_COMMAND+if [[ -z "${PROMPT_COMMAND}" ]]; then+ PROMPT_COMMAND="_arbor_prompt_hook"+else+ PROMPT_COMMAND="${PROMPT_COMMAND}; _arbor_prompt_hook"+fi+++----- stderr -----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.snapnew file mode 100644index 000000000..f8848abbc--- /dev/null+++ b/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap@@ -0,0 +1,60 @@+---+source: tests/integration_tests/init.rs+info:+ program: arbor+ args:+ - init+ - bash+ - "--cmd"+ - wt+ env:+ 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 -----+# arbor shell integration for bash++# Helper function to parse arbor output and handle directives+_arbor_exec() {+ local output line exit_code+ output="$("arbor" "$@" 2>&1)"+ exit_code=$?++ # Parse output line by line+ while IFS= read -r line; do+ if [[ "$line" == __ARBOR_CD__* ]]; then+ # Extract path and change directory+ \cd "${line#__ARBOR_CD__}"+ else+ # Regular output - print it+ echo "$line"+ fi+ done <<< "$output"++ return $exit_code+}++# Main commands that support directory changes+wt-switch() {+ _arbor_exec switch --internal "$@"+}++wt-finish() {+ _arbor_exec finish --internal "$@"+}++# Convenience aliases+alias wt-sw='wt-switch'+alias wt-fin='wt-finish'++++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_bash_prompt_hook.snap b/tests/snapshots/integration__integration_tests__init__init_bash_prompt_hook.snapnew file mode 100644index 000000000..4734ed7ab--- /dev/null+++ b/tests/snapshots/integration__integration_tests__init__init_bash_prompt_hook.snap@@ -0,0 +1,73 @@+---+source: tests/integration_tests/init.rs+info:+ program: arbor+ args:+ - init+ - bash+ - "--hook"+ - prompt+ env:+ 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 -----+# arbor shell integration for bash++# Helper function to parse arbor output and handle directives+_arbor_exec() {+ local output line exit_code+ output="$("arbor" "$@" 2>&1)"+ exit_code=$?++ # Parse output line by line+ while IFS= read -r line; do+ if [[ "$line" == __ARBOR_CD__* ]]; then+ # Extract path and change directory+ \cd "${line#__ARBOR_CD__}"+ else+ # Regular output - print it+ echo "$line"+ fi+ done <<< "$output"++ return $exit_code+}++# Main commands that support directory changes+arbor-switch() {+ _arbor_exec switch --internal "$@"+}++arbor-finish() {+ _arbor_exec finish --internal "$@"+}++# Convenience aliases+alias arbor-sw='arbor-switch'+alias arbor-fin='arbor-finish'+++# Prompt hook for tracking current worktree+_arbor_prompt_hook() {+ # Call arbor to update tracking+ command arbor hook prompt 2>/dev/null || true+}++# Add to PROMPT_COMMAND+if [[ -z "${PROMPT_COMMAND}" ]]; then+ PROMPT_COMMAND="_arbor_prompt_hook"+else+ PROMPT_COMMAND="${PROMPT_COMMAND}; _arbor_prompt_hook"+fi+++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snapnew file mode 100644index 000000000..50f278f61--- /dev/null+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap@@ -0,0 +1,57 @@+---+source: tests/integration_tests/init.rs+info:+ program: arbor+ args:+ - init+ - fish+ env:+ 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 -----+# arbor shell integration for fish++# Helper function to parse arbor output and handle directives+function _arbor_exec+ set -l output (arbor $argv 2>&1)+ set -l exit_code $status++ # Parse output line by line+ for line in $output+ if string match -q '__ARBOR_CD__*' -- $line+ # Extract path and change directory+ cd (string sub -s 14 -- $line)+ else+ # Regular output - print it+ echo $line+ end+ end++ return $exit_code+end++# Main commands that support directory changes+function arbor-switch+ _arbor_exec switch --internal $argv+end++function arbor-finish+ _arbor_exec finish --internal $argv+end++# Convenience aliases+alias arbor-sw='arbor-switch'+alias arbor-fin='arbor-finish'++++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_fish_prompt_hook.snap b/tests/snapshots/integration__integration_tests__init__init_fish_prompt_hook.snapnew file mode 100644index 000000000..2d121325e--- /dev/null+++ b/tests/snapshots/integration__integration_tests__init__init_fish_prompt_hook.snap@@ -0,0 +1,65 @@+---+source: tests/integration_tests/init.rs+info:+ program: arbor+ args:+ - init+ - fish+ - "--hook"+ - prompt+ env:+ 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 -----+# arbor shell integration for fish++# Helper function to parse arbor output and handle directives+function _arbor_exec+ set -l output (arbor $argv 2>&1)+ set -l exit_code $status++ # Parse output line by line+ for line in $output+ if string match -q '__ARBOR_CD__*' -- $line+ # Extract path and change directory+ cd (string sub -s 14 -- $line)+ else+ # Regular output - print it+ echo $line+ end+ end++ return $exit_code+end++# Main commands that support directory changes+function arbor-switch+ _arbor_exec switch --internal $argv+end++function arbor-finish+ _arbor_exec finish --internal $argv+end++# Convenience aliases+alias arbor-sw='arbor-switch'+alias arbor-fin='arbor-finish'+++# Prompt hook for tracking current worktree+function _arbor_prompt_hook --on-event fish_prompt+ # Call arbor to update tracking+ command arbor hook prompt 2>/dev/null; or true+end+++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_invalid_hook.snap b/tests/snapshots/integration__integration_tests__init__init_invalid_hook.snapnew file mode 100644index 000000000..4053efbb1--- /dev/null+++ b/tests/snapshots/integration__integration_tests__init__init_invalid_hook.snap@@ -0,0 +1,25 @@+---+source: tests/integration_tests/init.rs+info:+ program: arbor+ args:+ - init+ - bash+ - "--hook"+ - invalid+ env:+ 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 -----++----- stderr -----+Error: Git command failed: Invalid hook mode: invaliddiff --git a/tests/snapshots/integration__integration_tests__init__init_invalid_shell.snap b/tests/snapshots/integration__integration_tests__init__init_invalid_shell.snapnew file mode 100644index 000000000..2211a1639--- /dev/null+++ b/tests/snapshots/integration__integration_tests__init__init_invalid_shell.snap@@ -0,0 +1,23 @@+---+source: tests/integration_tests/init.rs+info:+ program: arbor+ args:+ - init+ - invalid-shell+ env:+ 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 -----++----- stderr -----+Error: Git command failed: Unsupported shell: invalid-shelldiff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snapnew file mode 100644index 000000000..18babaacb--- /dev/null+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap@@ -0,0 +1,58 @@+---+source: tests/integration_tests/init.rs+info:+ program: arbor+ args:+ - init+ - zsh+ env:+ 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 -----+# arbor shell integration for zsh++# Helper function to parse arbor output and handle directives+_arbor_exec() {+ local output line exit_code+ output="$("arbor" "$@" 2>&1)"+ exit_code=$?++ # Parse output line by line+ while IFS= read -r line; do+ if [[ "$line" == __ARBOR_CD__* ]]; then+ # Extract path and change directory+ \cd "${line#__ARBOR_CD__}"+ else+ # Regular output - print it+ echo "$line"+ fi+ done <<< "$output"++ return $exit_code+}++# Main commands that support directory changes+arbor-switch() {+ _arbor_exec switch --internal "$@"+}++arbor-finish() {+ _arbor_exec finish --internal "$@"+}++# Convenience aliases+alias arbor-sw='arbor-switch'+alias arbor-fin='arbor-finish'++++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__detached_head.snap b/tests/snapshots/integration__integration_tests__list__detached_head.snapnew file mode 100644index 000000000..dab2ee001--- /dev/null+++ b/tests/snapshots/integration__integration_tests__list__detached_head.snap@@ -0,0 +1,25 @@+---+source: tests/integration_tests/list.rs+info:+ program: arbor+ args:+ - list+ env:+ 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 -----+[REPO]+ HEAD: [SHA]+ (detached)+++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap b/tests/snapshots/integration__integration_tests__list__locked_no_reason.snapnew file mode 100644index 000000000..66a5860f8--- /dev/null+++ b/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap@@ -0,0 +1,30 @@+---+source: tests/integration_tests/list.rs+info:+ program: arbor+ args:+ - list+ env:+ 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 -----+[REPO]+ HEAD: [SHA]+ branch: main++[WORKTREE_LOCKED_NO_REASON]+ HEAD: [SHA]+ branch: locked-no-reason+ (locked)+++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__locked_worktree.snap b/tests/snapshots/integration__integration_tests__list__locked_worktree.snapnew file mode 100644index 000000000..270a8230b--- /dev/null+++ b/tests/snapshots/integration__integration_tests__list__locked_worktree.snap@@ -0,0 +1,30 @@+---+source: tests/integration_tests/list.rs+info:+ program: arbor+ args:+ - list+ env:+ 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 -----+[REPO]+ HEAD: [SHA]+ branch: main++[WORKTREE_LOCKED_FEATURE]+ HEAD: [SHA]+ branch: locked-feature+ (locked: Testing lock functionality)+++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap b/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snapnew file mode 100644index 000000000..ce9c5fc10--- /dev/null+++ b/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap@@ -0,0 +1,33 @@+---+source: tests/integration_tests/list.rs+info:+ program: arbor+ args:+ - list+ env:+ 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 -----+[REPO]+ HEAD: [SHA]+ branch: main++[WORKTREE_FEATURE_A]+ HEAD: [SHA]+ branch: feature-a++[WORKTREE_FEATURE_B]+ HEAD: [SHA]+ branch: feature-b+++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__single_worktree.snap b/tests/snapshots/integration__integration_tests__list__single_worktree.snapnew file mode 100644index 000000000..f3f7cf977--- /dev/null+++ b/tests/snapshots/integration__integration_tests__list__single_worktree.snap@@ -0,0 +1,25 @@+---+source: tests/integration_tests/list.rs+info:+ program: arbor+ args:+ - list+ env:+ 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 -----+[REPO]+ HEAD: [SHA]+ branch: main+++----- stderr -----