Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat: Capitalize command phase names for display

Maximilian Roos962d6949fe7a
diff --git a/src/config/commands.rs b/src/config/commands.rs
index b929b47fa..bacfbd440 100644
--- a/src/config/commands.rs
+++ b/src/config/commands.rs
@@ -7,7 +7,7 @@ use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
/// Phase in which a command executes
-#[derive(Debug, Clone, Copy, PartialEq, Eq, strum::Display, strum::AsRefStr)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, strum::AsRefStr)]
#[strum(serialize_all = "kebab-case")]
pub enum CommandPhase {
/// After creating a worktree (blocking)
@@ -22,6 +22,18 @@ pub enum CommandPhase {
PostMerge,
}
+impl std::fmt::Display for CommandPhase {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let s = self.as_ref();
+ // Capitalize first letter: "pre-commit" -> "Pre-commit"
+ let mut chars = s.chars();
+ match chars.next() {
+ None => Ok(()),
+ Some(first) => write!(f, "{}{}", first.to_uppercase(), chars.as_str()),
+ }
+ }
+}
+
/// Represents a command with its template and optionally expanded form
#[derive(Debug, Clone, PartialEq)]
pub struct Command {
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap
index cf0326374..bc0f3311a 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap
@@ -4,7 +4,7 @@ expression: combined
---
exit_code: 0
----- stdout -----
-βšͺ post-create declined
+βšͺ Post-create declined
βœ… Created new worktree for test-mixed from main at [REPO].test-mixed
πŸ’‘
πŸ’‘ To enable automatic cd, run: wt config shell
@@ -13,10 +13,10 @@ exit_code: 0
🟑 test-repo wants to execute 2 commands:
-πŸ”„ post-create:
+πŸ”„ Post-create:
  echo 'First command'
-πŸ”„ post-create:
+πŸ”„ Post-create:
  echo 'Third command'
πŸ’‘ Allow and remember? [y/N]
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap
index 309fa4e5e..117efc135 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap
@@ -4,7 +4,7 @@ expression: combined
---
exit_code: 0
----- stdout -----
-βšͺ post-create declined
+βšͺ Post-create declined
βœ… Created new worktree for test/nested-branch from main at [REPO].test-nested-branch
πŸ’‘
πŸ’‘ To enable automatic cd, run: wt config shell
@@ -13,16 +13,16 @@ exit_code: 0
🟑 test-repo wants to execute 4 commands:
-πŸ”„ post-create:
+πŸ”„ Post-create:
  echo 'Branch: test-nested-branch'
-πŸ”„ post-create:
+πŸ”„ Post-create:
  echo 'Worktree: [REPO].test-nested-branch'
-πŸ”„ post-create:
+πŸ”„ Post-create:
  echo 'Repo: test-repo'
-πŸ”„ post-create:
+πŸ”„ Post-create:
  cd [REPO].test-nested-branch && pwd
πŸ’‘ Allow and remember? [y/N]
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap
index fd86d0cc3..3460b2ddf 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap
@@ -4,7 +4,7 @@ expression: combined
---
exit_code: 0
----- stdout -----
-βšͺ post-create declined
+βšͺ Post-create declined
βœ… Created new worktree for test-named from main at [REPO].test-named
πŸ’‘
πŸ’‘ To enable automatic cd, run: wt config shell
@@ -13,13 +13,13 @@ exit_code: 0
🟑 test-repo wants to execute 3 commands:
-πŸ”„ post-create install:
+πŸ”„ Post-create install:
  echo 'Installing dependencies...'
-πŸ”„ post-create build:
+πŸ”„ Post-create build:
  echo 'Building project...'
-πŸ”„ post-create test:
+πŸ”„ Post-create test:
  echo 'Running tests...'
πŸ’‘ Allow and remember? [y/N]
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap
index ac3446f27..5044ccd00 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap
@@ -4,7 +4,7 @@ expression: combined
---
exit_code: 0
----- stdout -----
-βšͺ post-create declined
+βšͺ Post-create declined
βœ… Created new worktree for feature/test-approval from main at [REPO].feature-test-approval
πŸ’‘
πŸ’‘ To enable automatic cd, run: wt config shell
@@ -13,7 +13,7 @@ exit_code: 0
🟑 test-repo wants to execute 1 command:
-πŸ”„ post-create:
+πŸ”„ Post-create:
  echo 'Worktree path: [REPO].feature-test-approval'
πŸ’‘ Allow and remember? [y/N]
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap b/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap
index 27796facd..f7fde6acc 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap
@@ -4,7 +4,7 @@ expression: combined
---
exit_code: 0
----- stdout -----
-βšͺ post-create declined
+βšͺ Post-create declined
βœ… Created new worktree for test-decline from main at [REPO].test-decline
πŸ’‘
πŸ’‘ To enable automatic cd, run: wt config shell
@@ -13,10 +13,10 @@ exit_code: 0
🟑 test-repo wants to execute 2 commands:
-πŸ”„ post-create:
+πŸ”„ Post-create:
  echo 'First command'
-πŸ”„ post-create:
+πŸ”„ Post-create:
  echo 'Third command'
πŸ’‘ Allow and remember? [y/N]
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_second_run.snap b/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_second_run.snap
index 547b2550b..232527d05 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_second_run.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_second_run.snap
@@ -4,7 +4,7 @@ expression: combined
---
exit_code: 0
----- stdout -----
-βšͺ post-create declined
+βšͺ Post-create declined
βœ… Created new worktree for test-force-2 from main at [REPO].test-force-2
πŸ’‘
πŸ’‘ To enable automatic cd, run: wt config shell
@@ -13,7 +13,7 @@ exit_code: 0
🟑 test-repo wants to execute 1 command:
-πŸ”„ post-create:
+πŸ”„ Post-create:
  echo 'test command' > output.txt
πŸ’‘ Allow and remember? [y/N]