Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: add --no-ff flag to wt step push (#1587)
worktrunk-botf43fca7f7545
diff --git a/src/cli/step.rs b/src/cli/step.rsindex 2c3e95fa7..eb7d425f7 100644--- a/src/cli/step.rs+++ b/src/cli/step.rs@@ -148,6 +148,14 @@ Similar to `git push . HEAD:<target>`, but uses `receive.denyCurrentBranch=updat/// Defaults to default branch.#[arg(add = crate::completion::branch_value_completer())]target: Option<String>,++ /// Create a merge commit (no fast-forward)+ #[arg(long = "no-ff", overrides_with = "ff")]+ no_ff: bool,++ /// Allow fast-forward (default)+ #[arg(long, overrides_with = "no_ff", hide = true)]+ ff: bool,},/// Rebase onto targetdiff --git a/src/main.rs b/src/main.rsindex 548f050cf..9c41345bf 100644--- a/src/main.rs+++ b/src/main.rs@@ -43,7 +43,7 @@ pub(crate) use crate::cli::OutputFormat;#[cfg(unix)]use commands::handle_select;-use commands::worktree::handle_push;+use commands::worktree::{handle_no_ff_merge, handle_push};use commands::{MergeOptions, OperationMode, RebaseResult, SquashResult, SwitchOptions, add_approvals,clear_approvals, handle_completions, handle_config_create, handle_config_show,@@ -267,7 +267,15 @@ fn handle_step_command(action: StepCommand) -> anyhow::Result<()> {})}}- StepCommand::Push { target } => handle_push(target.as_deref(), "Pushed to", None),+ StepCommand::Push { target, no_ff, .. } => {+ if no_ff {+ let repo = Repository::current()?;+ let current_branch = repo.require_current_branch("step push --no-ff")?;+ handle_no_ff_merge(target.as_deref(), None, ¤t_branch)+ } else {+ handle_push(target.as_deref(), "Pushed to", None)+ }+ }StepCommand::Rebase { target } => {handle_rebase(target.as_deref()).map(|result| match result {RebaseResult::Rebased => (),diff --git a/tests/integration_tests/push.rs b/tests/integration_tests/push.rsindex 54ae3ccd1..4d8ff40ec 100644--- a/tests/integration_tests/push.rs+++ b/tests/integration_tests/push.rs@@ -228,6 +228,33 @@ fn test_push_with_merge_commits(mut repo: TestRepo) {);}+#[rstest]+fn test_push_no_ff(mut repo: TestRepo) {+ repo.add_main_worktree();++ let feature_wt =+ repo.add_worktree_with_commit("feature", "test.txt", "test content", "Add test file");++ // Push with --no-ff should create a merge commit on main+ snapshot_push("push_no_ff", &repo, &["--no-ff", "main"], Some(&feature_wt));++ // Verify a merge commit was created (HEAD on main should have 2 parents)+ let cat_file = repo.git_output(&["cat-file", "-p", "main"]);+ let parents: Vec<&str> = cat_file+ .lines()+ .filter(|l| l.starts_with("parent "))+ .collect();+ assert_eq!(+ parents.len(),+ 2,+ "Merge commit should have exactly 2 parents"+ );++ // Verify the merge commit message+ let commit_msg = repo.git_output(&["log", "-1", "--format=%s", "main"]);+ assert_eq!(commit_msg, "Merge branch 'feature' into main");+}+#[rstest]fn test_push_no_remote(#[from(repo_with_feature_worktree)] repo: TestRepo) {// Note: repo_with_feature_worktree doesn't call setup_remote(), so this tests the "no remote" error casediff --git a/tests/snapshots/integration__integration_tests__push__push_no_ff.snap b/tests/snapshots/integration__integration_tests__push__push_no_ff.snapnew file mode 100644index 000000000..1cc648982--- /dev/null+++ b/tests/snapshots/integration__integration_tests__push__push_no_ff.snap@@ -0,0 +1,51 @@+---+source: tests/integration_tests/push.rs+info:+ program: wt+ args:+ - step+ - push+ - "--no-ff"+ - main+ env:+ APPDATA: "[TEST_CONFIG_HOME]"+ CLICOLOR_FORCE: "1"+ COLUMNS: "500"+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"+ GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""+ GIT_TERMINAL_PROMPT: "0"+ HOME: "[TEST_HOME]"+ LANG: C+ LC_ALL: C+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"+ NO_COLOR: ""+ PATH: "[PATH]"+ PSModulePath: ""+ RUST_LOG: warn+ SHELL: ""+ TERM: alacritty+ USERPROFILE: "[TEST_HOME]"+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"+ WORKTRUNK_TEST_EPOCH: "1735776000"+ WORKTRUNK_TEST_NUSHELL_ENV: "0"+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+[36m◎[39m [36mMerging 1 commit to [1mmain[22m @ [2m[HASH][22m (--no-ff)[39m+[107m [0m * [33m[HASH][m Add test file+[107m [0m test.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+[32m✓[39m [32mMerged to [1mmain[22m @ [2m[HASH][22m [90m(1 commit, 1 file, [32m+1[39m, --no-ff[39m[90m)[39m[39m