Skip to content

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.rs
index 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(), @"
✗ Cannot remove worktree after merge: feature-auth has uncommitted changes
-  M auth.rs
- ?? .DS_Store
+   M auth.rs
+   ?? .DS_Store
↳ Commit or stash changes first
");
}
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.snap
index 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.rs
expression: err.render()
---
✗ Cannot remove worktree after merge: feature-auth has uncommitted changes
-  M auth.rs
- ?? .DS_Store
+  M auth.rs
+  ?? .DS_Store
↳ Commit or stash changes first
diff --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.snap
index 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: C
LC_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 -----
✗ Cannot merge with --no-commit: feature has uncommitted changes
- ?? dirty.txt
+  ?? dirty.txt
↳ Commit or stash changes first
diff --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.snap
index 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: C
LC_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 -----
✗ Cannot merge with --no-commit: feature has uncommitted changes
- ?? uncommitted.txt
+  ?? uncommitted.txt
↳ Commit or stash changes first
diff --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.snap
index 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: C
LC_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 -----
✗ Cannot remove worktree: feature-dirty has uncommitted changes
- ?? dirty.txt
+  ?? dirty.txt
↳ Commit or stash changes first, or to lose uncommitted changes, run wt remove --force feature-dirty
diff --git a/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_main.snap b/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_main.snap
index 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: C
LC_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 -----
✗ Cannot promote: main has uncommitted changes
- ?? dirty.txt
+  ?? dirty.txt
↳ Commit or stash changes first
diff --git a/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_target.snap b/tests/snapshots/integration__integration_tests__step_promote__promote_dirty_target.snap
index 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: C
LC_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 -----
✗ Cannot promote: feature has uncommitted changes
- ?? dirty.txt
+  ?? dirty.txt
↳ Commit or stash changes first