Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
docs: Remove unnecessary newlines in error formatting
Maximilian Roos77bc28ac5d44
diff --git a/CLAUDE.md b/CLAUDE.mdindex 139b4ae83..b3807c38f 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -376,6 +376,16 @@ super::gutter(format_with_gutter(&error.to_string(), "", None))?; // Adds ❌ eprint!("{}", format_with_gutter(&command));```+**Linebreaks with gutter content:** Use a single newline (`\n`) between error messages and gutter content, never double newlines (`\n\n`). The gutter's visual structure (background color, indentation) provides sufficient separation - blank lines are redundant.++```rust+// ✅ GOOD - single newline before gutter+format!("{header}\n{}", format_with_gutter(error, "", None))++// ❌ BAD - double newline creates unnecessary blank line+format!("{header}\n\n{}", format_with_gutter(error, "", None))+```+### Snapshot Testing Requirementdiff --git a/src/git/error.rs b/src/git/error.rsindex 37d671b35..06fdbd76a 100644--- a/src/git/error.rs+++ b/src/git/error.rs@@ -331,7 +331,7 @@ fn format_error_block(header: String, error: &str) -> String {if trimmed.is_empty() {header} else {- format!("{header}\n\n{}", format_with_gutter(trimmed, "", None))+ format!("{header}\n{}", format_with_gutter(trimmed, "", None))}}diff --git a/src/git/repository/mod.rs b/src/git/repository/mod.rsindex 35a0ade90..81cf06d0d 100644--- a/src/git/repository/mod.rs+++ b/src/git/repository/mod.rs@@ -43,7 +43,7 @@ impl<T, E: std::fmt::Display> GitResultExt<T> for Result<T, E> {let error_str = e.to_string();let header = format!("{ERROR_EMOJI} {ERROR}{context}{ERROR:#}");// External errors always use gutter formatting (canonical path)- let formatted = format!("{}\n\n{}", header, format_with_gutter(&error_str, "", None));+ let formatted = format!("{}\n{}", header, format_with_gutter(&error_str, "", None));GitError::CommandFailed(formatted)})}diff --git a/tests/integration_tests/directives.rs b/tests/integration_tests/directives.rsindex 2284e291f..bbefd76d4 100644--- a/tests/integration_tests/directives.rs+++ b/tests/integration_tests/directives.rs@@ -28,7 +28,6 @@ fn test_switch_internal_directive() {exit_code: 1----- stdout -----❌ [31mFailed to create worktree for [1m[31mmy-feature[0m[0m-[40m [0m fatal: invalid reference: my-feature@@ -58,7 +57,6 @@ fn test_switch_without_internal() {exit_code: 1----- stdout -----❌ [31mFailed to create worktree for [1m[31mmy-feature[0m[0m-[40m [0m fatal: invalid reference: my-featurediff --git a/tests/snapshots/git_error_display__push_failed.snap b/tests/snapshots/git_error_display__push_failed.snapindex 77c73ccf2..09c89630a 100644--- a/tests/snapshots/git_error_display__push_failed.snap+++ b/tests/snapshots/git_error_display__push_failed.snap@@ -3,7 +3,6 @@ source: tests/git_error_display.rsexpression: err.to_string()---❌ [31mPush failed[0m-[40m [0m To /Users/user/workspace/repo/.git[40m [0m ! [remote rejected] HEAD -> main (Up-to-date check failed)[40m [0m error: failed to push some refs to '/Users/user/workspace/repo/.git'diff --git a/tests/snapshots/git_error_display__worktree_removal_failed.snap b/tests/snapshots/git_error_display__worktree_removal_failed.snapindex 28394cd2b..bb23044d2 100644--- a/tests/snapshots/git_error_display__worktree_removal_failed.snap+++ b/tests/snapshots/git_error_display__worktree_removal_failed.snap@@ -3,6 +3,5 @@ source: tests/git_error_display.rsexpression: err.to_string()---❌ [31mFailed to remove worktree for [1m[31mfeature-x[0m[31m at [1m[31m/tmp/repo.feature-x[0m[0m-[40m [0m fatal: worktree is dirty[40m [0m error: could not remove worktreediff --git a/tests/snapshots/integration__integration_tests__merge__merge_primary_on_different_branch_dirty.snap b/tests/snapshots/integration__integration_tests__merge__merge_primary_on_different_branch_dirty.snapindex c825227ea..1331d6c04 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_primary_on_different_branch_dirty.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_primary_on_different_branch_dirty.snap@@ -16,7 +16,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpiUrIVl/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpxaDqD2/test-config.toml---success: falseexit_code: 1@@ -31,7 +31,6 @@ exit_code: 1✅ [32mMerged to [1m[32mmain[0m[0m (1 commit, 1 file, [32m+1[0m)🔄 [36mSwitching to [1m[36mmain[0m[36m...[0m❌ [31mFailed to switch to [1m[31mmain[0m[0m-[40m [0m error: Your local changes to the following files would be overwritten by checkout:[40m [0m file.txt[40m [0m Please commit your changes or stash them before you switch branches.diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap b/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snapindex 65c20b6b3..b54a3ee5d 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap@@ -17,13 +17,12 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmprBFTsP/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp4vXfy1/test-config.toml---success: falseexit_code: 1----- stdout -----❌ [31mFailed to load project config[0m-[40m [0m Failed to parse TOML: TOML parse error at line 1, column 39[40m [0m |[40m [0m 1 | post-create-command = [invalid syntaxdiff --git a/tests/snapshots/integration__integration_tests__security__error_message_with_directive_not_executed.snap b/tests/snapshots/integration__integration_tests__security__error_message_with_directive_not_executed.snapindex ffe17808b..cbd68cfde 100644--- a/tests/snapshots/integration__integration_tests__security__error_message_with_directive_not_executed.snap+++ b/tests/snapshots/integration__integration_tests__security__error_message_with_directive_not_executed.snap@@ -17,13 +17,12 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJfokz4/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpXCg30j/test-config.toml---success: falseexit_code: 1----- stdout -----❌ [31mFailed to create worktree for [1m[31m__WORKTRUNK_EXEC__echo PWNED > /tmp/hacked6[0m[0m-[40m [0m fatal: invalid reference: __WORKTRUNK_EXEC__echo PWNED > /tmp/hacked6