Skip to content

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

feat: Show HEAD SHA when no commits are pushed

Maximilian Roos6fca4f7baaf3
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index 3c59cd269..48524e0a6 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -626,7 +626,14 @@ pub fn handle_push(
summary_parts.join(", ")
))?;
} else {
- // No commits to push - for merge workflow context, acknowledge operations that didn't happen
+ // No commits to push - show current HEAD commit info
+ let head_sha = repo
+ .run_command(&["rev-parse", "--short", "HEAD"])?
+ .trim()
+ .to_string();
+ let green_dim = GREEN.dimmed();
+
+ // For merge workflow context, acknowledge operations that didn't happen
let note = if let Some(ops) = operations {
let mut notes = Vec::new();
if !ops.committed && !ops.squashed {
@@ -636,17 +643,17 @@ pub fn handle_push(
notes.push("no rebase needed");
}
if notes.is_empty() {
- String::new()
+ "already up to date".to_string()
} else {
- format!(" ({})", notes.join(", "))
+ notes.join(", ")
}
} else {
// Standalone push - no merge workflow context
- String::new()
+ "already up to date".to_string()
};
crate::output::success(format!(
- "{GREEN}{verb} {GREEN_BOLD}{target_branch}{GREEN_BOLD:#}{GREEN:#}{note}"
+ "{GREEN}{verb} {GREEN_BOLD}{target_branch}{GREEN_BOLD:#}{GREEN} @ {green_dim}{head_sha}{green_dim:#} ({note}){GREEN:#}"
))?;
}
diff --git a/tests/integration_tests/push.rs b/tests/integration_tests/push.rs
index 2ab9c691e..22f9f7ec0 100644
--- a/tests/integration_tests/push.rs
+++ b/tests/integration_tests/push.rs
@@ -6,10 +6,10 @@ use std::process::Command;
fn snapshot_push(test_name: &str, repo: &TestRepo, args: &[&str], cwd: Option<&std::path::Path>) {
let settings = setup_snapshot_settings(repo);
settings.bind(|| {
- // Prepend "push" to args for `wt beta push` command
- let mut beta_args = vec!["push"];
- beta_args.extend_from_slice(args);
- let mut cmd = make_snapshot_cmd(repo, "beta", &beta_args, cwd);
+ // Prepend "push" to args for `wt step push` command
+ let mut step_args = vec!["push"];
+ step_args.extend_from_slice(args);
+ let mut cmd = make_snapshot_cmd(repo, "step", &step_args, cwd);
assert_cmd_snapshot!(test_name, cmd);
});
}
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 c7dd3bb20..3f0426afd 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 (no new commits, no rebase needed)
+βœ… Merged to main @ [HASH] (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 4c0413bf9..0247706d5 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
@@ -20,7 +20,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-βœ… Merged to main (no new commits, no rebase needed)
+βœ… Merged to main @ [SHA] (no new commits, no rebase needed)
βœ… Worktree preserved (--no-remove)
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_default_branch_missing_worktree.snap b/tests/snapshots/integration__integration_tests__merge__merge_default_branch_missing_worktree.snap
index 4c0413bf9..0247706d5 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_default_branch_missing_worktree.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_default_branch_missing_worktree.snap
@@ -20,7 +20,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-βœ… Merged to main (no new commits, no rebase needed)
+βœ… Merged to main @ [SHA] (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 ce4e7f09e..0ce6ebb5e 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snap
@@ -21,7 +21,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-βœ… Merged to main (no new commits, no rebase needed)
+βœ… Merged to main @ [SHA] (no new commits, no rebase needed)
πŸ”„ Removing no-commits worktree & branch in background
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_rebase_fast_forward.snap b/tests/snapshots/integration__integration_tests__merge__merge_rebase_fast_forward.snap
index 92d95fd4b..eeb030b9b 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_rebase_fast_forward.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_rebase_fast_forward.snap
@@ -22,7 +22,7 @@ success: true
exit_code: 0
----- stdout -----
βœ… Fast-forwarded to main
-βœ… Merged to main (no new commits)
+βœ… Merged to main @ [SHA] (no new commits)
πŸ”„ Removing fast-forward-test worktree & branch in background
----- 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 66e4df432..4b372ab01 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
@@ -31,7 +31,7 @@ exit_code: 0
  - Change 2
  - Revert to initial
βšͺ No changes after squashing 3 commits
-βœ… Merged to main (no new commits, no rebase needed)
+βœ… Merged to main @ [SHA] (no new commits, no rebase needed)
πŸ”„ Removing feature worktree & branch in background
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__push__push_dirty_target_autostash.snap b/tests/snapshots/integration__integration_tests__push__push_dirty_target_autostash.snap
index d0a87910e..a8eda5eca 100644
--- a/tests/snapshots/integration__integration_tests__push__push_dirty_target_autostash.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_dirty_target_autostash.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/push.rs
info:
program: wt
args:
- - beta
+ - step
- push
- main
env:
@@ -19,13 +19,15 @@ info:
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
---
-success: false
-exit_code: 2
+success: true
+exit_code: 0
----- stdout -----
+πŸ”„ Stashing changes in [REPO]...
+πŸ”„ Pushing 1 commit to main @ [SHA]
+  * [SHA] Add feature file
+  feature.txt | 1 +
+  1 file changed, 1 insertion(+)
+πŸ”„ Restoring stashed changes in [REPO]...
+βœ… Pushed to main (1 commit, 1 file, +1)
----- stderr -----
-error: unrecognized subcommand 'push'
-
-Usage: wt beta [OPTIONS] <COMMAND>
-
-For more information, try '--help'.
diff --git a/tests/snapshots/integration__integration_tests__push__push_dirty_target_overlap.snap b/tests/snapshots/integration__integration_tests__push__push_dirty_target_overlap.snap
index d0a87910e..46dfe315f 100644
--- a/tests/snapshots/integration__integration_tests__push__push_dirty_target_overlap.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_dirty_target_overlap.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/push.rs
info:
program: wt
args:
- - beta
+ - step
- push
- main
env:
@@ -20,12 +20,12 @@ info:
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
---
success: false
-exit_code: 2
+exit_code: 1
----- stdout -----
+❌ Cannot push: conflicting uncommitted changes in:
------ stderr -----
-error: unrecognized subcommand 'push'
+  conflict.txt
-Usage: wt beta [OPTIONS] <COMMAND>
+πŸ’‘ Commit or stash these changes in [REPO] first
-For more information, try '--help'.
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__push__push_error_not_fast_forward.snap b/tests/snapshots/integration__integration_tests__push__push_error_not_fast_forward.snap
index d0a87910e..a5af86bec 100644
--- a/tests/snapshots/integration__integration_tests__push__push_error_not_fast_forward.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_error_not_fast_forward.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/push.rs
info:
program: wt
args:
- - beta
+ - step
- push
- main
env:
@@ -20,12 +20,11 @@ info:
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
---
success: false
-exit_code: 2
+exit_code: 1
----- stdout -----
+❌ Can't push to local main branch: it has newer commits
+  * [SHA] Main commit
------ stderr -----
-error: unrecognized subcommand 'push'
-
-Usage: wt beta [OPTIONS] <COMMAND>
+πŸ’‘ Use 'wt merge' to rebase your changes onto main
-For more information, try '--help'.
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap b/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap
index d0a87910e..3cacc93a3 100644
--- a/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/push.rs
info:
program: wt
args:
- - beta
+ - step
- push
- main
env:
@@ -20,12 +20,10 @@ info:
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
---
success: false
-exit_code: 2
+exit_code: 1
----- stdout -----
+❌ Found merge commits in push range
------ stderr -----
-error: unrecognized subcommand 'push'
-
-Usage: wt beta [OPTIONS] <COMMAND>
+πŸ’‘ Use --allow-merge-commits to push non-linear history
-For more information, try '--help'.
+----- stderr -----
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 d0a87910e..3da685fa6 100644
--- a/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/push.rs
info:
program: wt
args:
- - beta
+ - step
- push
- main
env:
@@ -19,13 +19,13 @@ info:
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
---
-success: false
-exit_code: 2
+success: true
+exit_code: 0
----- stdout -----
+πŸ”„ Pushing 1 commit to main @ [SHA]
+  * [SHA] Add test file
+  test.txt | 1 +
+  1 file changed, 1 insertion(+)
+βœ… Pushed to main (1 commit, 1 file, +1)
----- stderr -----
-error: unrecognized subcommand 'push'
-
-Usage: wt beta [OPTIONS] <COMMAND>
-
-For more information, try '--help'.
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 0f3eeb555..ba56952f1 100644
--- a/tests/snapshots/integration__integration_tests__push__push_no_remote.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_no_remote.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/push.rs
info:
program: wt
args:
- - beta
+ - step
- push
env:
CLICOLOR_FORCE: "1"
@@ -18,13 +18,13 @@ info:
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
---
-success: false
-exit_code: 2
+success: true
+exit_code: 0
----- stdout -----
+πŸ”„ Pushing 1 commit to main @ [SHA]
+  * [SHA] Add feature file
+  feature.txt | 1 +
+  1 file changed, 1 insertion(+)
+βœ… Pushed to main (1 commit, 1 file, +1)
----- stderr -----
-error: unrecognized subcommand 'push'
-
-Usage: wt beta [OPTIONS] <COMMAND>
-
-For more information, try '--help'.
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 d0a87910e..1c3a50c1e 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
@@ -3,7 +3,7 @@ source: tests/integration_tests/push.rs
info:
program: wt
args:
- - beta
+ - step
- push
- main
env:
@@ -19,13 +19,13 @@ info:
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
---
-success: false
-exit_code: 2
+success: true
+exit_code: 0
----- stdout -----
+πŸ”„ Pushing 1 commit to main @ [SHA]
+  * [SHA] Add feature file
+  feature.txt | 1 +
+  1 file changed, 1 insertion(+)
+βœ… Pushed to main (1 commit, 1 file, +1)
----- stderr -----
-error: unrecognized subcommand 'push'
-
-Usage: wt beta [OPTIONS] <COMMAND>
-
-For more information, try '--help'.
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 0f3eeb555..ba56952f1 100644
--- a/tests/snapshots/integration__integration_tests__push__push_to_default.snap
+++ b/tests/snapshots/integration__integration_tests__push__push_to_default.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/push.rs
info:
program: wt
args:
- - beta
+ - step
- push
env:
CLICOLOR_FORCE: "1"
@@ -18,13 +18,13 @@ info:
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
---
-success: false
-exit_code: 2
+success: true
+exit_code: 0
----- stdout -----
+πŸ”„ Pushing 1 commit to main @ [SHA]
+  * [SHA] Add feature file
+  feature.txt | 1 +
+  1 file changed, 1 insertion(+)
+βœ… Pushed to main (1 commit, 1 file, +1)
----- stderr -----
-error: unrecognized subcommand 'push'
-
-Usage: wt beta [OPTIONS] <COMMAND>
-
-For more information, try '--help'.
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 e28caf33f..dcc8bc512 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
@@ -3,7 +3,7 @@ source: tests/integration_tests/push.rs
info:
program: wt
args:
- - beta
+ - step
- push
- main
- "--allow-merge-commits"
@@ -20,13 +20,18 @@ info:
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
---
-success: false
-exit_code: 2
+success: true
+exit_code: 0
----- stdout -----
+πŸ”„ Pushing 3 commits to main @ [SHA] (merge commits allowed)
+  * [SHA] Merge temp
+  |/
+  | * [SHA] Commit 2
+  |/
+  * [SHA] Commit 1
+  file1.txt | 1 +
+  file2.txt | 1 +
+  2 files changed, 2 insertions(+)
+βœ… Pushed to main (3 commits, 2 files, +2)
----- stderr -----
-error: unrecognized subcommand 'push'
-
-Usage: wt beta [OPTIONS] <COMMAND>
-
-For more information, try '--help'.