Skip to content
This repository was archived by the owner on Nov 3, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/commands/worktree/cli_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@ pub struct ExecArgs {
/// Start from a specific commit-ish (ephemeral only)
pub commit_ish: Option<String>,

/// Only run in specified repos (comma-separated)
/// Only run in these repos (comma-separated): each value is a repo's alias,
/// its whole path in the set (. for the root), never part of one
#[arg(long, value_delimiter = ',')]
pub include: Vec<String>,

/// Skip specified repos (comma-separated)
/// Skip these repos (comma-separated), named like --include
#[arg(long, value_delimiter = ',')]
pub exclude: Vec<String>,

Expand Down
39 changes: 19 additions & 20 deletions src/commands/worktree/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ use anyhow::Result;
use colored::*;
use std::path::Path;

use meta_cli::repo_filter;
use meta_cli::worktree::{discover_worktree_repos, WorktreeRepoInfo};
use meta_git_lib::worktree::helpers::*;

use super::cli_types::{CreateArgs, DestroyArgs, ExecArgs};
use crate::git_env;

/// Runs in each of `repos`, naming them by their path from `wt_dir`.
/// Runs in each of `repos` that `--include`/`--exclude` select (by alias:
/// its path from `wt_dir`), naming them by that path.
fn build_loop_config(
wt_dir: &Path,
repos: &[WorktreeRepoInfo],
Expand All @@ -17,20 +19,19 @@ fn build_loop_config(
parallel: bool,
verbose: bool,
json: bool,
) -> loop_lib::LoopConfig {
loop_lib::LoopConfig {
directories: repos.iter().map(|r| r.path.display().to_string()).collect(),
) -> Result<loop_lib::LoopConfig> {
let directories: Vec<String> = repos.iter().map(|r| r.path.display().to_string()).collect();
// A member sits at its alias, so its path in the set is its name
let directories = repo_filter::select(
&include_filters,
&exclude_filters,
&directories,
wt_dir,
&[],
)?;
Ok(loop_lib::LoopConfig {
directories,
ignore: vec![],
include_filters: if include_filters.is_empty() {
None
} else {
Some(include_filters)
},
exclude_filters: if exclude_filters.is_empty() {
None
} else {
Some(exclude_filters)
},
verbose,
silent: false,
parallel,
Expand All @@ -41,7 +42,7 @@ fn build_loop_config(
env: Some(git_env::git_env()),
max_parallel: None,
root_dir: Some(wt_dir.to_path_buf()),
}
})
}

/// RAII guard that removes an ephemeral worktree on drop.
Expand Down Expand Up @@ -84,7 +85,6 @@ pub(crate) fn handle_exec(args: ExecArgs, verbose: bool, json: bool) -> Result<(
let name = &args.name;
let repos = discover_and_validate_worktree(name)?;

let command_str = args.command.join(" ");
let config = build_loop_config(
&resolve_existing_worktree(name)?.wt_dir,
&repos,
Expand All @@ -93,9 +93,9 @@ pub(crate) fn handle_exec(args: ExecArgs, verbose: bool, json: bool) -> Result<(
args.parallel,
verbose,
json,
);
)?;

loop_lib::run(&config, &command_str)?;
loop_lib::run(&config, &args.command)?;
Ok(())
}

Expand Down Expand Up @@ -152,7 +152,6 @@ fn handle_ephemeral_exec(args: ExecArgs, verbose: bool, json: bool) -> Result<()
// Run the command
let repos = discover_worktree_repos(&wt_dir)?;

let command_str = cmd_parts.join(" ");
let config = build_loop_config(
&wt_dir,
&repos,
Expand All @@ -163,7 +162,7 @@ fn handle_ephemeral_exec(args: ExecArgs, verbose: bool, json: bool) -> Result<()
json,
);

let exec_result = loop_lib::run(&config, &command_str);
let exec_result = config.and_then(|config| loop_lib::run(&config, &cmd_parts));

// Explicitly drop guard to trigger cleanup before propagating result
drop(guard);
Expand Down
6 changes: 3 additions & 3 deletions src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ pub(crate) fn execute_git_commit(
execute_editor_commit(&repos_with_changes)?;
} else if let Some(msg) = message {
// Apply same message to all repos - use ExecutionPlan for proper dry-run support
// Escape the message for shell (replace single quotes)
let escaped_msg = msg.replace('\'', "'\\''");
let commands: Vec<PlannedCommand> = repos_with_changes
.iter()
.map(|(name, path, _files)| {
Expand All @@ -93,7 +91,9 @@ pub(crate) fn execute_git_commit(
};
PlannedCommand {
dir,
cmd: format!("git commit -m '{escaped_msg}'"),
argv: ["git", "commit", "-m", msg.as_str()]
.map(str::to_string)
.to_vec(),
env: None,
}
})
Expand Down
Loading
Loading