Skip to content

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

feat: improve push message formatting

Maximilian Roosae0c3bc79f72
diff --git a/src/commands/beta.rs b/src/commands/beta.rs
index 9bac29b37..d9230f9a6 100644
--- a/src/commands/beta.rs
+++ b/src/commands/beta.rs
@@ -172,9 +172,6 @@ pub fn handle_beta_squash(
// Handle different scenarios
if commit_count == 0 && !has_staged {
// No commits and no staged changes - nothing to squash
- crate::output::hint(format!(
- "{HINT}No commits to squash - already at merge base{HINT:#}"
- ))?;
return Ok(false);
}
@@ -278,14 +275,7 @@ pub fn handle_beta_squash(
/// Handle `wt beta push` command
pub fn handle_beta_push(target: Option<&str>, allow_merge_commits: bool) -> Result<(), GitError> {
- super::worktree::handle_push(
- target,
- allow_merge_commits,
- "Pushed to",
- false,
- false,
- false,
- )
+ super::worktree::handle_push(target, allow_merge_commits, "Pushed to", None, None, None)
}
/// Handle `wt beta rebase` command
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index 6eb57f34e..0b45aa450 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -219,9 +219,9 @@ pub fn handle_merge(
Some(&target_branch),
false,
"Merged to",
- committed,
- squashed,
- rebased,
+ Some(committed),
+ Some(squashed),
+ Some(rebased),
)?;
// Get primary worktree path before cleanup (while we can still run git commands)
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index 85836dd74..f48610b89 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -629,13 +629,18 @@ pub fn execute_post_start_commands_sequential(
Ok(())
}
+/// Push changes to target branch
+///
+/// The `committed`, `squashed`, and `rebased` parameters are optional flags indicating
+/// whether those operations occurred in the merge workflow. Pass `None` for standalone
+/// push operations where these concepts don't apply.
pub fn handle_push(
target: Option<&str>,
allow_merge_commits: bool,
verb: &str,
- committed: bool,
- squashed: bool,
- rebased: bool,
+ committed: Option<bool>,
+ squashed: Option<bool>,
+ rebased: Option<bool>,
) -> Result<(), GitError> {
let repo = Repository::current();
@@ -724,17 +729,19 @@ pub fn handle_push(
// Build parenthetical showing which operations didn't happen and flags used
let mut notes = Vec::new();
- // Skipped operations
- let mut skipped_ops = Vec::new();
- if !committed && !squashed {
- // Neither commit nor squash happened - combine them
- skipped_ops.push("commit/squash");
- }
- if !rebased {
- skipped_ops.push("rebase");
- }
- if !skipped_ops.is_empty() {
- notes.push(format!("no {} needed", skipped_ops.join("/")));
+ // Skipped operations - only include if we're in merge workflow context (Some values)
+ if committed.is_some() || squashed.is_some() || rebased.is_some() {
+ let mut skipped_ops = Vec::new();
+ if !committed.unwrap_or(false) && !squashed.unwrap_or(false) {
+ // Neither commit nor squash happened - combine them
+ skipped_ops.push("commit/squash");
+ }
+ if !rebased.unwrap_or(false) {
+ skipped_ops.push("rebase");
+ }
+ if !skipped_ops.is_empty() {
+ notes.push(format!("no {} needed", skipped_ops.join("/")));
+ }
}
// Flag acknowledgments
@@ -804,8 +811,27 @@ pub fn handle_push(
summary_parts.join(", ")
))?;
} else {
+ // No commits to push - for merge workflow context, acknowledge operations that didn't happen
+ let note = if committed.is_some() || squashed.is_some() || rebased.is_some() {
+ let mut notes = Vec::new();
+ if !committed.unwrap_or(false) && !squashed.unwrap_or(false) {
+ notes.push("no new commits");
+ }
+ if !rebased.unwrap_or(false) {
+ notes.push("no rebase needed");
+ }
+ if notes.is_empty() {
+ String::new()
+ } else {
+ format!(" ({})", notes.join(", "))
+ }
+ } else {
+ // Standalone push - no merge workflow context
+ String::new()
+ };
+
crate::output::success(format!(
- "{GREEN}{verb} {GREEN_BOLD}{target_branch}{GREEN_BOLD:#}{GREEN:#}"
+ "{GREEN}{verb} {GREEN_BOLD}{target_branch}{GREEN_BOLD:#}{GREEN:#}{note}"
))?;
}
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snap
index 2cb4877cf..c7dd3bb20 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snap
@@ -2,5 +2,5 @@
source: tests/integration_tests/shell_wrapper.rs
expression: output.normalized()
---
-βœ… Merged to main
+βœ… Merged to main (no new commits, no rebase needed)
βœ… Worktree preserved (--no-remove)
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap b/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap
index 6b1594551..a025de8e1 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap
@@ -15,13 +15,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpKgm0sH/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp8fxCaQ/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ’‘ No commits to squash - already at merge base
-βœ… Merged to main
+βœ… Merged to main (no new commits, no rebase needed)
βœ… Worktree preserved (--no-remove)
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snap b/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snap
index ab7137a09..da4eb515f 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snap
@@ -16,13 +16,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpFeWEub/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpF7qHqU/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ’‘ No commits to squash - already at merge base
-βœ… Merged to main
+βœ… Merged to main (no new commits, no rebase needed)
βœ… Returned to primary at [REPO]
πŸ”„ Removing worktree & branch...
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_no_remote.snap b/tests/snapshots/integration__integration_tests__merge__merge_no_remote.snap
index 537c98b5d..a09f3c248 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_no_remote.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_no_remote.snap
@@ -15,13 +15,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpP0JvO5/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpKQDc8U/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ’‘ No commits to squash - already at merge base
-βœ… Merged to feature
+βœ… Merged to feature (no new commits, no rebase needed)
βœ… Worktree preserved (--no-remove)
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_empty_changes.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_empty_changes.snap
index d50501e76..cac44fd80 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_empty_changes.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_empty_changes.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpn0ZfDz/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpqY4lHd/test-config.toml
---
success: true
exit_code: 0
@@ -31,7 +31,7 @@ exit_code: 0
  - Change 2
  - Revert to initial
βšͺ No changes after squashing 3 commits
-βœ… Merged to main
+βœ… Merged to main (no new commits, no rebase needed)
βœ… Returned to primary at [REPO]
πŸ”„ Removing worktree & branch...
diff --git a/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap b/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap
index 5e5b348df..c1cd4b69d 100644
--- a/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap
@@ -17,12 +17,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpMEHg8I/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp9lwhzS/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ”„ Pushing 1 commit to main @ [SHA] (no commit/squash/rebase needed)
+πŸ”„ Pushing 1 commit to main @ [SHA]
  * [SHA] (HEAD -> feature) Add test file
  test.txt | 1 +
diff --git a/tests/snapshots/integration__integration_tests__push__push_no_remote.snap b/tests/snapshots/integration__integration_tests__push__push_no_remote.snap
index a749b466e..364e3bb9f 100644
--- a/tests/snapshots/integration__integration_tests__push__push_no_remote.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_no_remote.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp2mIKTU/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp1vgEVL/test-config.toml
---
success: true
exit_code: 0
diff --git a/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap b/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap
index c0565ca11..75ab9d601 100644
--- a/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_not_fast_forward.snap
@@ -17,12 +17,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpaGsNOh/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpFzk5oq/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ”„ Pushing 1 commit to main @ [SHA] (no commit/squash/rebase needed)
+πŸ”„ Pushing 1 commit to main @ [SHA]
  * [SHA] (HEAD -> feature) Add feature file
  feature.txt | 1 +
diff --git a/tests/snapshots/integration__integration_tests__push__push_to_default.snap b/tests/snapshots/integration__integration_tests__push__push_to_default.snap
index a26db1649..3742b88bc 100644
--- a/tests/snapshots/integration__integration_tests__push__push_to_default.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_to_default.snap
@@ -16,12 +16,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpyt5cTo/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpRuxKWq/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ”„ Pushing 1 commit to main @ [SHA] (no commit/squash/rebase needed)
+πŸ”„ Pushing 1 commit to main @ [SHA]
  * [SHA] (HEAD -> feature) Add feature file
  feature.txt | 1 +
diff --git a/tests/snapshots/integration__integration_tests__push__push_with_merge_commits_allowed.snap b/tests/snapshots/integration__integration_tests__push__push_with_merge_commits_allowed.snap
index 8bc59c4b7..12c49ea33 100644
--- a/tests/snapshots/integration__integration_tests__push__push_with_merge_commits_allowed.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_with_merge_commits_allowed.snap
@@ -18,12 +18,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpqnDjqt/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpApNe4v/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ”„ Pushing 3 commits to main @ [SHA] (no commit/squash/rebase needed, merge commits allowed)
+πŸ”„ Pushing 3 commits to main @ [SHA] (merge commits allowed)
  * [SHA] (HEAD -> feature) Merge temp
  |/