Skip to content

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

refactor: Extract commit logic into a dedicated file

Maximilian Roos6388af5d832e
diff --git a/src/cli.rs b/src/cli.rs
index 551ecaa88..73e3e28cc 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -67,7 +67,7 @@ pub enum ConfigCommand {
}
#[derive(Subcommand)]
-pub enum BetaCommand {
+pub enum StandaloneCommand {
/// Run a project hook for testing
RunHook {
/// Hook type to run
@@ -157,10 +157,10 @@ pub enum Commands {
},
/// Development and testing utilities
- #[command(hide = true)]
- Beta {
+ #[command(name = "beta", hide = true)]
+ Standalone {
#[command(subcommand)]
- action: BetaCommand,
+ action: StandaloneCommand,
},
/// List worktrees and optionally branches
diff --git a/src/commands/commit.rs b/src/commands/commit.rs
new file mode 100644
index 000000000..4327d3add
--- /dev/null
+++ b/src/commands/commit.rs
@@ -0,0 +1,242 @@
+use std::path::Path;
+use worktrunk::HookType;
+use worktrunk::config::{CommandPhase, CommitGenerationConfig, ProjectConfig, WorktrunkConfig};
+use worktrunk::git::{GitError, GitResultExt, Repository};
+use worktrunk::styling::{AnstyleStyle, CYAN, GREEN, HINT, WARNING, format_with_gutter};
+
+use super::hooks::{HookFailureStrategy, HookPipeline};
+use super::project_config::load_project_config;
+
+/// Options for committing current changes.
+pub struct CommitOptions<'a> {
+ pub repo: &'a Repository,
+ pub config: &'a WorktrunkConfig,
+ pub worktree_path: &'a Path,
+ pub current_branch: &'a str,
+ pub target_branch: Option<&'a str>,
+ pub no_verify: bool,
+ pub force: bool,
+ pub tracked_only: bool,
+ pub auto_trust: bool,
+ pub warn_about_untracked: bool,
+ pub show_no_squash_note: bool,
+}
+
+impl<'a> CommitOptions<'a> {
+ /// Convenience constructor for the common case where untracked files should trigger a warning.
+ pub fn new(
+ repo: &'a Repository,
+ config: &'a WorktrunkConfig,
+ worktree_path: &'a Path,
+ current_branch: &'a str,
+ ) -> Self {
+ Self {
+ repo,
+ config,
+ worktree_path,
+ current_branch,
+ target_branch: None,
+ no_verify: false,
+ force: false,
+ tracked_only: false,
+ auto_trust: false,
+ warn_about_untracked: true,
+ show_no_squash_note: false,
+ }
+ }
+}
+
+/// Format a commit message with the first line in bold, ready for gutter display.
+pub fn format_commit_message_for_display(message: &str) -> String {
+ let bold = AnstyleStyle::new().bold();
+ let lines: Vec<&str> = message.lines().collect();
+
+ if lines.is_empty() {
+ return String::new();
+ }
+
+ let mut result = format!("{bold}{}{bold:#}", lines[0]);
+
+ if lines.len() > 1 {
+ for line in &lines[1..] {
+ result.push('\n');
+ result.push_str(line);
+ }
+ }
+
+ result
+}
+
+/// Show hint if no LLM command is configured.
+pub fn show_llm_config_hint_if_needed(
+ commit_generation_config: &CommitGenerationConfig,
+) -> Result<(), GitError> {
+ if !commit_generation_config.is_configured() {
+ crate::output::hint(format!(
+ "{HINT}Using fallback commit message. Run 'wt config help' to configure LLM-generated messages{HINT:#}"
+ ))?;
+ }
+ Ok(())
+}
+
+fn get_untracked_files(status_output: &str) -> Vec<String> {
+ status_output
+ .lines()
+ .filter_map(|line| line.strip_prefix("?? "))
+ .map(|filename| filename.to_string())
+ .collect()
+}
+
+/// Warn about untracked files being auto-staged.
+pub fn warn_untracked_auto_stage(repo: &Repository) -> Result<(), GitError> {
+ let status = repo
+ .run_command(&["status", "--porcelain"])
+ .git_context("Failed to get status")?;
+ let untracked = get_untracked_files(&status);
+
+ if untracked.is_empty() {
+ return Ok(());
+ }
+
+ let file_list = untracked.join(", ");
+ crate::output::warning(format!(
+ "{WARNING}Auto-staging untracked files: {file_list}{WARNING:#}"
+ ))?;
+
+ Ok(())
+}
+
+/// Commit already-staged changes with LLM-generated or fallback message.
+pub fn commit_staged_changes(
+ commit_generation_config: &CommitGenerationConfig,
+ show_no_squash_note: bool,
+) -> Result<(), GitError> {
+ let repo = Repository::current();
+
+ let stats_parts = repo.diff_stats_summary(&["diff", "--staged", "--shortstat"]);
+
+ let action = if commit_generation_config.is_configured() {
+ "Generating commit message and committing..."
+ } else {
+ "Committing with default message..."
+ };
+
+ let mut parts = vec![];
+ if !stats_parts.is_empty() {
+ parts.extend(stats_parts);
+ }
+ if show_no_squash_note {
+ parts.push("no squashing needed".to_string());
+ }
+
+ let full_progress_msg = if parts.is_empty() {
+ format!("{CYAN}{action}{CYAN:#}")
+ } else {
+ format!("{CYAN}{action}{CYAN:#} ({})", parts.join(", "))
+ };
+
+ crate::output::progress(full_progress_msg)?;
+
+ show_llm_config_hint_if_needed(commit_generation_config)?;
+ let commit_message = crate::llm::generate_commit_message(commit_generation_config)?;
+
+ let formatted_message = format_commit_message_for_display(&commit_message);
+ crate::output::gutter(format_with_gutter(&formatted_message, "", None))?;
+
+ repo.run_command(&["commit", "-m", &commit_message])
+ .git_context("Failed to commit")?;
+
+ let commit_hash = repo
+ .run_command(&["rev-parse", "--short", "HEAD"])?
+ .trim()
+ .to_string();
+
+ let green_dim = GREEN.dimmed();
+ crate::output::success(format!(
+ "{GREEN}Committed changes @ {green_dim}{commit_hash}{green_dim:#}{GREEN:#}"
+ ))?;
+
+ Ok(())
+}
+
+/// Commit uncommitted changes with the shared commit pipeline.
+pub fn commit_changes(options: CommitOptions<'_>) -> Result<(), GitError> {
+ if !options.no_verify
+ && let Some(project_config) = load_project_config(options.repo)?
+ {
+ run_pre_commit_commands(
+ &project_config,
+ options.current_branch,
+ options.worktree_path,
+ options.repo,
+ options.config,
+ options.force,
+ options.target_branch,
+ options.auto_trust,
+ )?;
+ }
+
+ if options.warn_about_untracked && !options.tracked_only {
+ warn_untracked_auto_stage(options.repo)?;
+ }
+
+ if options.tracked_only {
+ options
+ .repo
+ .run_command(&["add", "-u"])
+ .git_context("Failed to stage tracked changes")?;
+ } else {
+ options
+ .repo
+ .run_command(&["add", "-A"])
+ .git_context("Failed to stage changes")?;
+ }
+
+ commit_staged_changes(
+ &options.config.commit_generation,
+ options.show_no_squash_note,
+ )
+}
+
+/// Run pre-commit commands sequentially (blocking, fail-fast).
+#[allow(clippy::too_many_arguments)]
+pub fn run_pre_commit_commands(
+ project_config: &ProjectConfig,
+ current_branch: &str,
+ worktree_path: &Path,
+ repo: &Repository,
+ config: &WorktrunkConfig,
+ force: bool,
+ target_branch: Option<&str>,
+ auto_trust: bool,
+) -> Result<(), GitError> {
+ let Some(pre_commit_config) = &project_config.pre_commit_command else {
+ return Ok(());
+ };
+
+ let repo_root = repo.worktree_base()?;
+ let pipeline = HookPipeline::new(
+ repo,
+ config,
+ current_branch,
+ worktree_path,
+ &repo_root,
+ force,
+ );
+
+ let extra_vars: Vec<(&str, &str)> = target_branch
+ .into_iter()
+ .map(|target| ("target", target))
+ .collect();
+
+ pipeline.run_sequential(
+ pre_commit_config,
+ CommandPhase::PreCommit,
+ auto_trust,
+ &extra_vars,
+ "pre-commit",
+ HookFailureStrategy::FailFast {
+ hook_type: HookType::PreCommit,
+ },
+ )
+}
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index 579778156..dbadde1cf 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -1,13 +1,10 @@
-use std::path::Path;
use worktrunk::HookType;
use worktrunk::config::{Command, CommandPhase, ProjectConfig, WorktrunkConfig};
use worktrunk::git::{GitError, GitResultExt, Repository};
-use worktrunk::styling::{
- AnstyleStyle, CYAN, CYAN_BOLD, ERROR, ERROR_EMOJI, GREEN_BOLD, HINT, HINT_EMOJI, WARNING,
- format_with_gutter,
-};
+use worktrunk::styling::{CYAN, CYAN_BOLD, ERROR, ERROR_EMOJI, GREEN_BOLD, HINT, HINT_EMOJI};
use super::command_approval::approve_command_batch;
+use super::commit::{CommitOptions, commit_changes, warn_untracked_auto_stage};
use super::context::CommandEnv;
use super::hooks::{HookFailureStrategy, HookPipeline};
use super::project_config::load_project_config;
@@ -66,42 +63,6 @@ impl<'a> MergeCommandCollector<'a> {
}
}
-/// Extract untracked files from git status --porcelain output
-fn get_untracked_files(status_output: &str) -> Vec<String> {
- let mut untracked = Vec::new();
-
- for line in status_output.lines() {
- // Git status --porcelain format: XY filename
- // Untracked files have "??" status
- if let Some(filename) = line.strip_prefix("?? ") {
- untracked.push(filename.to_string());
- }
- }
-
- untracked
-}
-
-/// Warn about untracked files being auto-staged
-fn show_untracked_warning(repo: &Repository) -> Result<(), GitError> {
- let status = repo
- .run_command(&["status", "--porcelain"])
- .git_context("Failed to get status")?;
- let untracked = get_untracked_files(&status);
-
- if untracked.is_empty() {
- return Ok(());
- }
-
- // Format file list (comma-separated)
- let file_list = untracked.join(", ");
-
- crate::output::warning(format!(
- "{WARNING}Auto-staging untracked files: {file_list}{WARNING:#}"
- ))?;
-
- Ok(())
-}
-
pub fn handle_merge(
target: Option<&str>,
squash_enabled: bool,
@@ -156,7 +117,7 @@ pub fn handle_merge(
if squash_enabled {
// Warn about untracked files before staging
if !tracked_only {
- show_untracked_warning(&repo)?;
+ warn_untracked_auto_stage(&repo)?;
}
if tracked_only {
@@ -169,16 +130,16 @@ pub fn handle_merge(
false // Staged but didn't commit (will squash later)
} else {
// Commit immediately when not squashing
- handle_commit_changes(
- &repo,
- &config,
- &worktree_path,
- &current_branch,
- Some(&target_branch),
- no_verify,
- force,
- tracked_only,
- )?;
+ let mut options = CommitOptions::new(&repo, &config, &worktree_path, &current_branch);
+ options.target_branch = Some(&target_branch);
+ options.no_verify = no_verify;
+ options.force = force;
+ options.tracked_only = tracked_only;
+ options.auto_trust = true; // commands already approved in merge batch
+ options.warn_about_untracked = !tracked_only;
+ options.show_no_squash_note = true;
+
+ commit_changes(options)?;
true // Committed directly
}
} else {
@@ -194,7 +155,7 @@ pub fn handle_merge(
// Rebase onto target (skip if --no-commit) - track whether rebasing occurred
let rebased = if !no_commit {
- super::beta::handle_beta_rebase(Some(&target_branch))?
+ super::standalone::handle_standalone_rebase(Some(&target_branch))?
} else {
false
};
@@ -317,146 +278,9 @@ fn handle_merge_summary_output(primary_path: Option<&std::path::Path>) -> Result
Ok(())
}
-/// Format a commit message with the first line in bold, ready for gutter display
-pub fn format_commit_message_for_display(message: &str) -> String {
- let bold = AnstyleStyle::new().bold();
- let lines: Vec<&str> = message.lines().collect();
-
- if lines.is_empty() {
- return String::new();
- }
-
- // Format first line in bold
- let mut result = format!("{bold}{}{bold:#}", lines[0]);
-
- // Add remaining lines without bold
- if lines.len() > 1 {
- for line in &lines[1..] {
- result.push('\n');
- result.push_str(line);
- }
- }
-
- result
-}
-
-/// Show hint if no LLM command is configured
-pub fn show_llm_config_hint_if_needed(
- commit_generation_config: &worktrunk::config::CommitGenerationConfig,
-) -> Result<(), GitError> {
- if !commit_generation_config.is_configured() {
- crate::output::hint(format!(
- "{HINT}Using fallback commit message. Run 'wt config help' to configure LLM-generated messages{HINT:#}"
- ))?;
- }
- Ok(())
-}
-
-/// Commit already-staged changes with LLM-generated or fallback message
-pub fn commit_staged_changes(
- commit_generation_config: &worktrunk::config::CommitGenerationConfig,
- show_no_squash_note: bool,
-) -> Result<(), GitError> {
- let repo = Repository::current();
-
- // Get diff stats for staged changes
- let stats_parts = repo.diff_stats_summary(&["diff", "--staged", "--shortstat"]);
-
- // Format progress message based on whether we're using LLM or fallback
- let action = if commit_generation_config.is_configured() {
- "Generating commit message and committing..."
- } else {
- "Committing with default message..."
- };
-
- // Build the progress message with optional squash status
- let mut parts = vec![];
- if !stats_parts.is_empty() {
- parts.extend(stats_parts);
- }
- if show_no_squash_note {
- parts.push("no squashing needed".to_string());
- }
-
- let full_progress_msg = if parts.is_empty() {
- format!("{CYAN}{action}{CYAN:#}")
- } else {
- format!("{CYAN}{action}{CYAN:#} ({})", parts.join(", "))
- };
-
- crate::output::progress(full_progress_msg)?;
-
- show_llm_config_hint_if_needed(commit_generation_config)?;
- let commit_message = crate::llm::generate_commit_message(commit_generation_config)?;
-
- let formatted_message = format_commit_message_for_display(&commit_message);
- crate::output::gutter(format_with_gutter(&formatted_message, "", None))?;
-
- repo.run_command(&["commit", "-m", &commit_message])
- .git_context("Failed to commit")?;
-
- // Get commit hash for display
- let commit_hash = repo
- .run_command(&["rev-parse", "--short", "HEAD"])?
- .trim()
- .to_string();
-
- use worktrunk::styling::GREEN;
- let green_dim = GREEN.dimmed();
- crate::output::success(format!(
- "{GREEN}Committed changes @ {green_dim}{commit_hash}{green_dim:#}{GREEN:#}"
- ))?;
-
- Ok(())
-}
-
-/// Commit uncommitted changes with LLM-generated message.
-#[allow(clippy::too_many_arguments)]
-fn handle_commit_changes(
- repo: &Repository,
- config: &WorktrunkConfig,
- worktree_path: &Path,
- current_branch: &str,
- target_branch: Option<&str>,
- no_verify: bool,
- force: bool,
- tracked_only: bool,
-) -> Result<(), GitError> {
- if !no_verify && let Some(project_config) = load_project_config(repo)? {
- run_pre_commit_commands(
- &project_config,
- current_branch,
- worktree_path,
- repo,
- config,
- force,
- target_branch,
- true, // auto_trust: commands already approved in merge batch
- )?;
- }
-
- // Warn about untracked files before staging (only if using git add -A)
- if !tracked_only {
- show_untracked_warning(repo)?;
- }
-
- // Stage changes
- if tracked_only {
- repo.run_command(&["add", "-u"])
- .git_context("Failed to stage tracked changes")?;
- } else {
- repo.run_command(&["add", "-A"])
- .git_context("Failed to stage changes")?;
- }
-
- // Show "no squashing needed" since we're committing directly (not in squash mode)
- commit_staged_changes(&config.commit_generation, true)
-}
-
fn handle_squash(target_branch: &str, no_verify: bool, force: bool) -> Result<bool, GitError> {
- // Delegate to the atomic beta command
- // auto_trust=true because commands already approved in merge batch
- super::beta::handle_beta_squash(Some(target_branch), force, no_verify, true)
+ // Delegate to the shared standalone implementation (auto_trust=true: commands approved in batch)
+ super::standalone::handle_standalone_squash(Some(target_branch), force, no_verify, true)
}
/// Run pre-merge commands sequentially (blocking, fail-fast)
@@ -532,46 +356,3 @@ pub fn execute_post_merge_commands(
HookFailureStrategy::Warn,
)
}
-
-/// Run pre-commit commands sequentially (blocking, fail-fast)
-#[allow(clippy::too_many_arguments)]
-pub fn run_pre_commit_commands(
- project_config: &ProjectConfig,
- current_branch: &str,
- worktree_path: &std::path::Path,
- repo: &Repository,
- config: &WorktrunkConfig,
- force: bool,
- target_branch: Option<&str>,
- auto_trust: bool,
-) -> Result<(), GitError> {
- let Some(pre_commit_config) = &project_config.pre_commit_command else {
- return Ok(());
- };
-
- let repo_root = repo.worktree_base()?;
- let pipeline = HookPipeline::new(
- repo,
- config,
- current_branch,
- worktree_path,
- &repo_root,
- force,
- );
-
- let extra_vars: Vec<(&str, &str)> = target_branch
- .into_iter()
- .map(|target| ("target", target))
- .collect();
-
- pipeline.run_sequential(
- pre_commit_config,
- CommandPhase::PreCommit,
- auto_trust,
- &extra_vars,
- "pre-commit",
- HookFailureStrategy::FailFast {
- hook_type: HookType::PreCommit,
- },
- )
-}
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index b1ee2a24d..dca4a5d7d 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -1,6 +1,6 @@
-pub mod beta;
pub mod command_approval;
mod command_executor;
+pub mod commit;
pub mod completion;
pub mod config;
pub mod configure_shell;
@@ -13,12 +13,9 @@ pub mod process;
pub mod project_config;
#[cfg(unix)]
pub mod select;
+pub mod standalone;
pub mod worktree;
-pub use beta::{
- handle_beta_ask_approvals, handle_beta_commit, handle_beta_push, handle_beta_rebase,
- handle_beta_run_hook, handle_beta_squash,
-};
pub use completion::{handle_complete, handle_completion};
pub use config::{
handle_config_help, handle_config_init, handle_config_list, handle_config_refresh_cache,
@@ -29,6 +26,10 @@ pub use list::handle_list;
pub use merge::handle_merge;
#[cfg(unix)]
pub use select::handle_select;
+pub use standalone::{
+ handle_standalone_ask_approvals, handle_standalone_commit, handle_standalone_push,
+ handle_standalone_rebase, handle_standalone_run_hook, handle_standalone_squash,
+};
pub use worktree::{handle_remove, handle_switch};
// Re-export Shell from the canonical location
diff --git a/src/commands/beta.rs b/src/commands/standalone.rs
similarity index 91%
rename from src/commands/beta.rs
rename to src/commands/standalone.rs
index d9230f9a6..3319b5a45 100644
--- a/src/commands/beta.rs
+++ b/src/commands/standalone.rs
@@ -4,16 +4,17 @@ use worktrunk::styling::{
AnstyleStyle, CYAN, CYAN_BOLD, GREEN_BOLD, HINT, HINT_EMOJI, eprintln, format_with_gutter,
};
-use super::context::CommandEnv;
-use super::merge::{
- commit_staged_changes, execute_post_merge_commands, format_commit_message_for_display,
- run_pre_commit_commands, run_pre_merge_commands, show_llm_config_hint_if_needed,
+use super::commit::{
+ CommitOptions, commit_changes, commit_staged_changes, format_commit_message_for_display,
+ run_pre_commit_commands, show_llm_config_hint_if_needed,
};
+use super::context::CommandEnv;
+use super::merge::{execute_post_merge_commands, run_pre_merge_commands};
use super::project_config::{load_project_config, require_project_config};
use super::worktree::{execute_post_create_commands, execute_post_start_commands_sequential};
/// Handle `wt beta run-hook` command
-pub fn handle_beta_run_hook(hook_type: HookType, force: bool) -> Result<(), GitError> {
+pub fn handle_standalone_run_hook(hook_type: HookType, force: bool) -> Result<(), GitError> {
// Derive context from current environment
let CommandEnv {
repo,
@@ -94,7 +95,7 @@ fn check_hook_configured<T>(hook: &Option<T>, hook_type: HookType) -> Result<(),
}
/// Handle `wt beta commit` command
-pub fn handle_beta_commit(force: bool, no_verify: bool) -> Result<(), GitError> {
+pub fn handle_standalone_commit(force: bool, no_verify: bool) -> Result<(), GitError> {
let CommandEnv {
repo,
branch: current_branch,
@@ -102,26 +103,13 @@ pub fn handle_beta_commit(force: bool, no_verify: bool) -> Result<(), GitError>
worktree_path,
} = CommandEnv::current()?;
- // Run pre-commit hook unless --no-verify was specified
- if !no_verify && let Some(project_config) = load_project_config(&repo)? {
- // No target branch context for standalone commits
- run_pre_commit_commands(
- &project_config,
- &current_branch,
- &worktree_path,
- &repo,
- &config,
- force,
- None,
- false, // auto_trust: standalone command, needs approval
- )?;
- }
-
- // Stage all changes including untracked files
- repo.run_command(&["add", "-A"])
- .git_context("Failed to stage changes")?;
+ let mut options = CommitOptions::new(&repo, &config, &worktree_path, &current_branch);
+ options.no_verify = no_verify;
+ options.force = force;
+ options.auto_trust = false;
+ options.show_no_squash_note = false;
- commit_staged_changes(&config.commit_generation, false)
+ commit_changes(options)
}
/// Handle `wt beta squash` command
@@ -130,7 +118,7 @@ pub fn handle_beta_commit(force: bool, no_verify: bool) -> Result<(), GitError>
/// * `auto_trust` - If true, skip approval prompts for pre-commit commands (already approved in batch)
///
/// Returns true if a commit or squash operation occurred, false if nothing needed to be done
-pub fn handle_beta_squash(
+pub fn handle_standalone_squash(
target: Option<&str>,
force: bool,
no_verify: bool,
@@ -274,13 +262,16 @@ pub fn handle_beta_squash(
}
/// Handle `wt beta push` command
-pub fn handle_beta_push(target: Option<&str>, allow_merge_commits: bool) -> Result<(), GitError> {
+pub fn handle_standalone_push(
+ target: Option<&str>,
+ allow_merge_commits: bool,
+) -> Result<(), GitError> {
super::worktree::handle_push(target, allow_merge_commits, "Pushed to", None, None, None)
}
/// Handle `wt beta rebase` command
/// Returns true if rebasing occurred, false if already up-to-date
-pub fn handle_beta_rebase(target: Option<&str>) -> Result<bool, GitError> {
+pub fn handle_standalone_rebase(target: Option<&str>) -> Result<bool, GitError> {
let repo = Repository::current();
// Get target branch (default to default branch if not provided)
@@ -347,7 +338,7 @@ pub fn handle_beta_rebase(target: Option<&str>) -> Result<bool, GitError> {
}
/// Handle `wt beta ask-approvals` command - approve all commands in the project
-pub fn handle_beta_ask_approvals(force: bool, show_all: bool) -> Result<(), GitError> {
+pub fn handle_standalone_ask_approvals(force: bool, show_all: bool) -> Result<(), GitError> {
use super::command_approval::approve_command_batch;
use worktrunk::config::{CommandPhase, WorktrunkConfig};
diff --git a/src/main.rs b/src/main.rs
index 82946370a..900ca98b4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -17,15 +17,15 @@ pub use crate::cli::OutputFormat;
use commands::handle_select;
use commands::worktree::SwitchResult;
use commands::{
- ConfigAction, handle_beta_ask_approvals, handle_beta_commit, handle_beta_push,
- handle_beta_rebase, handle_beta_run_hook, handle_beta_squash, handle_complete,
- handle_completion, handle_config_help, handle_config_init, handle_config_list,
- handle_config_refresh_cache, handle_configure_shell, handle_init, handle_list, handle_merge,
- handle_remove, handle_switch,
+ ConfigAction, handle_complete, handle_completion, handle_config_help, handle_config_init,
+ handle_config_list, handle_config_refresh_cache, handle_configure_shell, handle_init,
+ handle_list, handle_merge, handle_remove, handle_standalone_ask_approvals,
+ handle_standalone_commit, handle_standalone_push, handle_standalone_rebase,
+ handle_standalone_run_hook, handle_standalone_squash, handle_switch,
};
use output::{execute_user_command, handle_remove_output, handle_switch_output};
-use cli::{BetaCommand, Cli, Commands, ConfigCommand};
+use cli::{Cli, Commands, ConfigCommand, StandaloneCommand};
fn main() {
let cli = Cli::parse();
@@ -156,22 +156,30 @@ fn main() {
.git_err()
}
},
- Commands::Beta { action } => match action {
- BetaCommand::RunHook { hook_type, force } => handle_beta_run_hook(hook_type, force),
- BetaCommand::Commit { force, no_verify } => handle_beta_commit(force, no_verify),
- BetaCommand::Squash {
+ Commands::Standalone { action } => match action {
+ StandaloneCommand::RunHook { hook_type, force } => {
+ handle_standalone_run_hook(hook_type, force)
+ }
+ StandaloneCommand::Commit { force, no_verify } => {
+ handle_standalone_commit(force, no_verify)
+ }
+ StandaloneCommand::Squash {
target,
force,
no_verify,
- } => handle_beta_squash(target.as_deref(), force, no_verify, false).map(|_| ()),
- BetaCommand::Push {
+ } => handle_standalone_squash(target.as_deref(), force, no_verify, false).map(|_| ()),
+ StandaloneCommand::Push {
target,
allow_merge_commits,
- } => handle_beta_push(target.as_deref(), allow_merge_commits),
- BetaCommand::Rebase { target } => handle_beta_rebase(target.as_deref()).map(|_| ()),
- BetaCommand::AskApprovals { force, all } => handle_beta_ask_approvals(force, all),
+ } => handle_standalone_push(target.as_deref(), allow_merge_commits),
+ StandaloneCommand::Rebase { target } => {
+ handle_standalone_rebase(target.as_deref()).map(|_| ())
+ }
+ StandaloneCommand::AskApprovals { force, all } => {
+ handle_standalone_ask_approvals(force, all)
+ }
#[cfg(unix)]
- BetaCommand::Select => handle_select(),
+ StandaloneCommand::Select => handle_select(),
},
Commands::List {
format,
diff --git a/tests/integration_tests/config_list.rs b/tests/integration_tests/config_list.rs
index 6deaa7a09..71deaafa4 100644
--- a/tests/integration_tests/config_list.rs
+++ b/tests/integration_tests/config_list.rs
@@ -161,10 +161,10 @@ fn test_config_list_outside_git_repo() {
success: true
exit_code: 0
----- stdout -----
- ⚪ Global Config: [TEMP_HOME]/.config/worktrunk/config.toml
- worktree-path = "../{main-worktree}.{branch}"
+ ⚪ Global Config: [TEMP_HOME]/.config/worktrunk/config.toml
+   worktree-path = "../{main-worktree}.{branch}"
- ⚪ Project Config: Not in a git repository
+ ⚪ Project Config: Not in a git repository
----- stderr -----
"#);