Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor(error): render UncommittedChanges dirty files in the gutter (#2887)
Maximilian Roosb68e10b8168d
diff --git a/src/git/error.rs b/src/git/error.rsindex 89d4b6596..83c1229df 100644--- a/src/git/error.rs+++ b/src/git/error.rs@@ -814,8 +814,9 @@ impl GitError {"Commit or stash changes first".to_string()};write!(f, "{}", error_message(&title))?;- for line in dirty_files {- write!(f, "\n {}", cformat!("<dim>{}</>", line))?;+ if !dirty_files.is_empty() {+ let joined = dirty_files.join("\n");+ write!(f, "\n{}", format_with_gutter(&joined, None))?;}write!(f, "\n{}", hint_message(hint))}@@ -2157,8 +2158,8 @@ mod tests {};assert_snapshot!(err.render(), @"[31m✗[39m [31mCannot remove worktree after merge: [1mfeature-auth[22m has uncommitted changes[39m- [2m M auth.rs[22m- [2m?? .DS_Store[22m+ [107m [0m M auth.rs+ [107m [0m ?? .DS_Store[2m↳[22m [2mCommit or stash changes first[22m");}diff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__uncommitted_changes_with_dirty_files.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__uncommitted_changes_with_dirty_files.snapindex 47f8fdc0f..6ff5ff26e 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__uncommitted_changes_with_dirty_files.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__uncommitted_changes_with_dirty_files.snap@@ -3,6 +3,6 @@ source: tests/integration_tests/git_error_display.rsexpression: err.render()---[31m✗[39m [31mCannot remove worktree after merge: [1mfeature-auth[22m has uncommitted changes[39m- [2m M auth.rs[22m- [2m?? .DS_Store[22m+[107m [0m M auth.rs+[107m [0m ?? .DS_Store[2m↳[22m [2mCommit or stash changes first[22mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_error_uncommitted_changes_with_no_commit.snap b/tests/snapshots/integration__integration_tests__merge__merge_error_uncommitted_changes_with_no_commit.snapindex 7a5dfd280..701b82065 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_error_uncommitted_changes_with_no_commit.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_error_uncommitted_changes_with_no_commit.snap@@ -25,6 +25,7 @@ info:HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"NO_COLOR: ""OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"@@ -39,9 +40,11 @@ info:WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"WORKTRUNK_TEST_BASH_INSTALLED: "0"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"@@ -56,5 +59,5 @@ exit_code: 1----- stderr -----[31m✗[39m [31mCannot merge with --no-commit: [1mfeature[22m has uncommitted changes[39m- [2m?? dirty.txt[22m+[107m [0m ?? dirty.txt[2m↳[22m [2mCommit or stash changes first[22mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_no_commit_with_dirty_tree.snap b/tests/snapshots/integration__integration_tests__merge__merge_no_commit_with_dirty_tree.snapindex 52ca755ab..3c3b5bddc 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_no_commit_with_dirty_tree.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_no_commit_with_dirty_tree.snap@@ -24,6 +24,7 @@ info:HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"NO_COLOR: ""OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"@@ -38,9 +39,11 @@ info:WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"WORKTRUNK_TEST_BASH_INSTALLED: "0"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"@@ -55,5 +58,5 @@ exit_code: 1----- stderr -----[31m✗[39m [31mCannot merge with --no-commit: [1mfeature[22m has uncommitted changes[39m- [2m?? uncommitted.txt[22m+[107m [0m ?? uncommitted.txt[2m↳[22m [2mCommit or stash changes first[22mdiff --git a/tests/snapshots/integration__integration_tests__remove__remove_by_name_dirty_target.snap b/tests/snapshots/integration__integration_tests__remove__remove_by_name_dirty_target.snapindex 114a5a218..f5cc6a0c1 100644--- a/tests/snapshots/integration__integration_tests__remove__remove_by_name_dirty_target.snap+++ b/tests/snapshots/integration__integration_tests__remove__remove_by_name_dirty_target.snap@@ -23,6 +23,7 @@ info:HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"NO_COLOR: ""OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"@@ -37,9 +38,11 @@ info:WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"WORKTRUNK_TEST_BASH_INSTALLED: "0"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"@@ -54,5 +57,5 @@ exit_code: 1----- stderr -----[31m✗[39m [31mCannot remove worktree: [1mfeature-dirty[22m has uncommitted changes[39m- [2m?? dirty.txt[22m+[107m [0m ?? dirty.txt[2m↳[22m [2mCommit or stash changes first, or to lose uncommitted changes, run [4mwt remove --force feature-dirty[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_main.snap b/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_main.snapindex 51b8bbec7..8a58aaf5e 100644--- a/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_main.snap+++ b/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_main.snap@@ -24,6 +24,7 @@ info:HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"NO_COLOR: ""OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"@@ -38,9 +39,11 @@ info:WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"WORKTRUNK_TEST_BASH_INSTALLED: "0"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"@@ -55,5 +58,5 @@ exit_code: 1----- stderr -----[31m✗[39m [31mCannot promote: [1mmain[22m has uncommitted changes[39m- [2m?? dirty.txt[22m+[107m [0m ?? dirty.txt[2m↳[22m [2mCommit or stash changes first[22mdiff --git a/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_target.snap b/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_target.snapindex bf096998c..51b3b33dd 100644--- a/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_target.snap+++ b/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_target.snap@@ -24,6 +24,7 @@ info:HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"NO_COLOR: ""OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"@@ -38,9 +39,11 @@ info:WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"WORKTRUNK_TEST_BASH_INSTALLED: "0"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"@@ -55,5 +58,5 @@ exit_code: 1----- stderr -----[31m✗[39m [31mCannot promote: [1mfeature[22m has uncommitted changes[39m- [2m?? dirty.txt[22m+[107m [0m ?? dirty.txt[2m↳[22m [2mCommit or stash changes first[22m