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.rsindex 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 happenlet 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.rsindex 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.snapindex 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.rsexpression: output.normalized()----β [32mMerged to [1m[32mmain[0m[0m (no new commits, no rebase needed)+β [32mMerged to [1m[32mmain[0m[32m @ [2m[32m[HASH][0m (no new commits, no rebase needed)[0mβ [32mWorktree preserved (--no-remove)[0mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap b/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snapindex 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: trueexit_code: 0----- stdout ------β [32mMerged to [1m[32mmain[0m[0m (no new commits, no rebase needed)+β [32mMerged to [1m[32mmain[0m[32m @ [2m[SHA] (no new commits, no rebase needed)[0mβ [32mWorktree preserved (--no-remove)[0m----- 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.snapindex 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: trueexit_code: 0----- stdout ------β [32mMerged to [1m[32mmain[0m[0m (no new commits, no rebase needed)+β [32mMerged to [1m[32mmain[0m[32m @ [2m[SHA] (no new commits, no rebase needed)[0mβ [32mWorktree preserved (--no-remove)[0m----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snap b/tests/snapshots/integration__integration_tests__merge__merge_no_commits.snapindex 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: trueexit_code: 0----- stdout ------β [32mMerged to [1m[32mmain[0m[0m (no new commits, no rebase needed)+β [32mMerged to [1m[32mmain[0m[32m @ [2m[SHA] (no new commits, no rebase needed)[0mπ [36mRemoving [1m[36mno-commits[0m[36m worktree & branch in background[0m----- 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.snapindex 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: trueexit_code: 0----- stdout -----β [32mFast-forwarded to [1m[32mmain[0m[0m-β [32mMerged to [1m[32mmain[0m[0m (no new commits)+β [32mMerged to [1m[32mmain[0m[32m @ [2m[SHA] (no new commits)[0mπ [36mRemoving [1m[36mfast-forward-test[0m[36m worktree & branch in background[0m----- 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.snapindex 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[107m [0m - Change 2[107m [0m - Revert to initialβͺ [2mNo changes after squashing 3 commits[0m-β [32mMerged to [1m[32mmain[0m[0m (no new commits, no rebase needed)+β [32mMerged to [1m[32mmain[0m[32m @ [2m[SHA] (no new commits, no rebase needed)[0mπ [36mRemoving [1m[36mfeature[0m[36m worktree & branch in background[0m----- 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.snapindex 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.rsinfo:program: wtargs:- - beta+ - step- push- mainenv:@@ -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 -----+π [36mStashing changes in [1m[36m[REPO][0m[36m...[0m+π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m+[107m [0m * [SHA] Add feature file+[107m [0m feature.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+π [36mRestoring stashed changes in [1m[36m[REPO][0m[36m...[0m+β [32mPushed to [1m[32mmain[0m[0m (1 commit, 1 file, [32m+1[0m)----- stderr ------[1m[31merror:[0m unrecognized subcommand '[1m[33mpush[0m'--[1m[32mUsage:[0m [1m[36mwt beta[0m [36m[OPTIONS][0m [36m<COMMAND>[0m--For more information, try '[1m[36m--help[0m'.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.snapindex 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.rsinfo:program: wtargs:- - beta+ - step- push- mainenv:@@ -20,12 +20,12 @@ info:WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"---success: false-exit_code: 2+exit_code: 1----- stdout -----+β [31mCannot push: conflicting uncommitted changes in:[0m------ stderr ------[1m[31merror:[0m unrecognized subcommand '[1m[33mpush[0m'+[107m [0m conflict.txt-[1m[32mUsage:[0m [1m[36mwt beta[0m [36m[OPTIONS][0m [36m<COMMAND>[0m+π‘ [2mCommit or stash these changes in [REPO] first[0m-For more information, try '[1m[36m--help[0m'.+----- 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.snapindex 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.rsinfo:program: wtargs:- - beta+ - step- push- mainenv:@@ -20,12 +20,11 @@ info:WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"---success: false-exit_code: 2+exit_code: 1----- stdout -----+β [31mCan't push to local [1m[31mmain[0m[31m branch: it has newer commits[0m+[107m [0m * [SHA] Main commit------ stderr ------[1m[31merror:[0m unrecognized subcommand '[1m[33mpush[0m'--[1m[32mUsage:[0m [1m[36mwt beta[0m [36m[OPTIONS][0m [36m<COMMAND>[0m+π‘ [2mUse 'wt merge' to rebase your changes onto main[0m-For more information, try '[1m[36m--help[0m'.+----- 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.snapindex 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.rsinfo:program: wtargs:- - beta+ - step- push- mainenv:@@ -20,12 +20,10 @@ info:WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"---success: false-exit_code: 2+exit_code: 1----- stdout -----+β [31mFound merge commits in push range[0m------ stderr ------[1m[31merror:[0m unrecognized subcommand '[1m[33mpush[0m'--[1m[32mUsage:[0m [1m[36mwt beta[0m [36m[OPTIONS][0m [36m<COMMAND>[0m+π‘ [2mUse --allow-merge-commits to push non-linear history[0m-For more information, try '[1m[36m--help[0m'.+----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__push__push_fast_forward.snap b/tests/snapshots/integration__integration_tests__push__push_fast_forward.snapindex 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.rsinfo:program: wtargs:- - beta+ - step- push- mainenv:@@ -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 -----+π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m+[107m [0m * [SHA] Add test file+[107m [0m test.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+β [32mPushed to [1m[32mmain[0m[0m (1 commit, 1 file, [32m+1[0m)----- stderr ------[1m[31merror:[0m unrecognized subcommand '[1m[33mpush[0m'--[1m[32mUsage:[0m [1m[36mwt beta[0m [36m[OPTIONS][0m [36m<COMMAND>[0m--For more information, try '[1m[36m--help[0m'.diff --git a/tests/snapshots/integration__integration_tests__push__push_no_remote.snap b/tests/snapshots/integration__integration_tests__push__push_no_remote.snapindex 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.rsinfo:program: wtargs:- - beta+ - step- pushenv: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 -----+π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m+[107m [0m * [SHA] Add feature file+[107m [0m feature.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+β [32mPushed to [1m[32mmain[0m[0m (1 commit, 1 file, [32m+1[0m)----- stderr ------[1m[31merror:[0m unrecognized subcommand '[1m[33mpush[0m'--[1m[32mUsage:[0m [1m[36mwt beta[0m [36m[OPTIONS][0m [36m<COMMAND>[0m--For more information, try '[1m[36m--help[0m'.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.snapindex 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.rsinfo:program: wtargs:- - beta+ - step- push- mainenv:@@ -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 -----+π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m+[107m [0m * [SHA] Add feature file+[107m [0m feature.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+β [32mPushed to [1m[32mmain[0m[0m (1 commit, 1 file, [32m+1[0m)----- stderr ------[1m[31merror:[0m unrecognized subcommand '[1m[33mpush[0m'--[1m[32mUsage:[0m [1m[36mwt beta[0m [36m[OPTIONS][0m [36m<COMMAND>[0m--For more information, try '[1m[36m--help[0m'.diff --git a/tests/snapshots/integration__integration_tests__push__push_to_default.snap b/tests/snapshots/integration__integration_tests__push__push_to_default.snapindex 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.rsinfo:program: wtargs:- - beta+ - step- pushenv: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 -----+π [36mPushing 1 commit to [1m[36mmain[0m[36m @ [2m[SHA][0m+[107m [0m * [SHA] Add feature file+[107m [0m feature.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+β [32mPushed to [1m[32mmain[0m[0m (1 commit, 1 file, [32m+1[0m)----- stderr ------[1m[31merror:[0m unrecognized subcommand '[1m[33mpush[0m'--[1m[32mUsage:[0m [1m[36mwt beta[0m [36m[OPTIONS][0m [36m<COMMAND>[0m--For more information, try '[1m[36m--help[0m'.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.snapindex 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.rsinfo:program: wtargs:- - 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 -----+π [36mPushing 3 commits to [1m[36mmain[0m[36m @ [2m[SHA][0m (merge commits allowed)+[107m [0m * [SHA] Merge temp+[107m [0m [31m|[m[32m/[m+[107m [0m [31m|[m * [SHA] Commit 2+[107m [0m [31m|[m[31m/[m+[107m [0m * [SHA] Commit 1+[107m [0m file1.txt | 1 [32m+[m+[107m [0m file2.txt | 1 [32m+[m+[107m [0m 2 files changed, 2 insertions(+)+β [32mPushed to [1m[32mmain[0m[0m (3 commits, 2 files, [32m+2[0m)----- stderr ------[1m[31merror:[0m unrecognized subcommand '[1m[33mpush[0m'--[1m[32mUsage:[0m [1m[36mwt beta[0m [36m[OPTIONS][0m [36m<COMMAND>[0m--For more information, try '[1m[36m--help[0m'.