From 49d0913751d4caba2e24d41250bc8be232ae3286 Mon Sep 17 00:00:00 2001 From: gold-silver-copper <157451540+gold-silver-copper@users.noreply.github.com> Date: Fri, 23 Oct 2026 16:32:19 -0700 Subject: [PATCH] feat: name worktree exec repos by their path from the worktree meta git worktree exec passed no root to loop_lib, so it named the root repo by its folder (t1) and children by basename, unlike meta git status in the same worktree. Pass the worktree dir as the root: '. (t1)', ./agent. Both callers passed the same git env, so build_loop_config sets it itself. Implements [[tasks/harmony-2712]] --- src/commands/worktree/exec.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/commands/worktree/exec.rs b/src/commands/worktree/exec.rs index 35b8918..b6e9ea8 100644 --- a/src/commands/worktree/exec.rs +++ b/src/commands/worktree/exec.rs @@ -1,24 +1,25 @@ use anyhow::Result; use colored::*; -use std::collections::HashMap; +use std::path::Path; -use meta_cli::worktree::discover_worktree_repos; +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`. fn build_loop_config( - directories: Vec, + wt_dir: &Path, + repos: &[WorktreeRepoInfo], include_filters: Vec, exclude_filters: Vec, parallel: bool, verbose: bool, json: bool, - env: Option>, ) -> loop_lib::LoopConfig { loop_lib::LoopConfig { - directories, + directories: repos.iter().map(|r| r.path.display().to_string()).collect(), ignore: vec![], include_filters: if include_filters.is_empty() { None @@ -37,9 +38,9 @@ fn build_loop_config( json_output: json, add_aliases_to_global_looprc: false, spawn_stagger_ms: 0, - env, + env: Some(git_env::git_env()), max_parallel: None, - root_dir: None, // Worktree exec paths don't use "." convention + root_dir: Some(wt_dir.to_path_buf()), } } @@ -83,17 +84,15 @@ pub(crate) fn handle_exec(args: ExecArgs, verbose: bool, json: bool) -> Result<( let name = &args.name; let repos = discover_and_validate_worktree(name)?; - let directories: Vec = repos.iter().map(|r| r.path.display().to_string()).collect(); - let command_str = args.command.join(" "); let config = build_loop_config( - directories, + &resolve_existing_worktree(name)?.wt_dir, + &repos, args.include, args.exclude, args.parallel, verbose, json, - Some(git_env::git_env()), ); loop_lib::run(&config, &command_str)?; @@ -152,17 +151,16 @@ fn handle_ephemeral_exec(args: ExecArgs, verbose: bool, json: bool) -> Result<() // Run the command let repos = discover_worktree_repos(&wt_dir)?; - let directories: Vec = repos.iter().map(|r| r.path.display().to_string()).collect(); let command_str = cmd_parts.join(" "); let config = build_loop_config( - directories, + &wt_dir, + &repos, include_filters, exclude_filters, parallel, verbose, json, - Some(git_env::git_env()), ); let exec_result = loop_lib::run(&config, &command_str);