From afe7c99e08e7a2dcc5e2df2fd5df11cbb7263318 Mon Sep 17 00:00:00 2001 From: gsc Date: Mon, 26 Oct 2026 15:56:07 -0700 Subject: [PATCH 1/5] fix(config): propagate project config discovery errors Adapt resolver callers while retaining recursive listings outermost root. [[tasks/harmony-2793]] --- src/lib.rs | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 17d6bbd..2bcedf7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -125,9 +125,13 @@ pub fn execute_command( } // The workspace's own config: the nearest one at or above cwd, as meta - // finds it (a config it can't read is returned, and reading it fails) - let Some((meta_path, _format)) = config::find_meta_config(cwd, None) else { - return CommandResult::Error(format!("No .meta config found in {}", escape_path(cwd))); + // finds it (ambiguity and unreadable configs are errors) + let meta_path = match config::find_meta_config(cwd, None) { + Ok(Some((path, _))) => path, + Ok(None) => { + return CommandResult::Error(format!("No .meta config found in {}", escape_path(cwd))) + } + Err(e) => return CommandResult::Error(format!("{e:#}")), }; let projects = match parse_meta_projects(&meta_path) { Ok(projects) => projects, @@ -340,14 +344,18 @@ fn handle_project_list(cwd: &Path, options: &ExecuteOptions) -> CommandResult { // When recursive, walk up to the root ancestor meta-repo let start_dir = if options.recursive { match config::find_meta_config(cwd, None) { - Some((config_path, _)) => { + Ok(Some((config_path, _))) => { let nearest_meta_dir = config_path .parent() .unwrap_or(std::path::Path::new(".")) .to_path_buf(); - config::find_root_meta_dir(&nearest_meta_dir) + match config::find_root_meta_dir(&nearest_meta_dir) { + Ok(root) => root, + Err(e) => return CommandResult::Error(format!("{e:#}")), + } } - None => { + Err(e) => return CommandResult::Error(format!("{e:#}")), + Ok(None) => { return CommandResult::Error(format!( "No .meta config found in {}", escape_path(cwd) @@ -380,8 +388,9 @@ fn handle_project_list(cwd: &Path, options: &ExecuteOptions) -> CommandResult { start_dir.clone() } else { match config::find_meta_config(cwd, None) { - Some((config_path, _)) => config_path.parent().unwrap_or(cwd).to_path_buf(), - None => start_dir.clone(), + Ok(Some((config_path, _))) => config_path.parent().unwrap_or(cwd).to_path_buf(), + Ok(None) => start_dir.clone(), + Err(e) => return CommandResult::Error(format!("{e:#}")), } }; let abs_root = root_dir @@ -567,12 +576,19 @@ fn handle_project_dependents( }; // Find the root meta config - let Some((nearest_meta_path, _)) = config::find_meta_config(cwd, None) else { - return CommandResult::Error(format!("No .meta config found in {}", escape_path(cwd))); + let nearest_meta_path = match config::find_meta_config(cwd, None) { + Ok(Some((path, _))) => path, + Ok(None) => { + return CommandResult::Error(format!("No .meta config found in {}", escape_path(cwd))) + } + Err(e) => return CommandResult::Error(format!("{e:#}")), }; let nearest_meta_dir = nearest_meta_path.parent().unwrap_or(Path::new(".")); let start_dir = if options.recursive { - config::find_root_meta_dir(nearest_meta_dir) + match config::find_root_meta_dir(nearest_meta_dir) { + Ok(root) => root, + Err(e) => return CommandResult::Error(format!("{e:#}")), + } } else { nearest_meta_dir.to_path_buf() }; From 4984b40ea05d120621e5a4e732d13014a07cd4c3 Mon Sep 17 00:00:00 2001 From: gsc Date: Mon, 26 Oct 2026 17:40:44 -0700 Subject: [PATCH 2/5] fix(project): project list refuses --include/--exclude itself [[tasks/harmony-2793]] --- src/lib.rs | 8 ++++++++ src/main.rs | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 2bcedf7..2507ace 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,8 @@ pub struct ExecuteOptions { pub depth: Option, pub verbose: bool, pub parallel: bool, + /// `--include` or `--exclude` was given + pub filtered: bool, } // ============================================================================ @@ -103,6 +105,12 @@ pub fn execute_command( // project list/ls handles its own config discovery if command == "project list" || command == "project ls" { + // It lists the whole tree, so a filter would be silently ignored + if options.filtered { + return CommandResult::Error( + "meta project list does not take --include/--exclude".to_string(), + ); + } // Check if --json was passed as a trailing arg (not extracted by meta_cli // because it could be intended for a subcommand in non-plugin contexts) let json_from_args = args.iter().any(|a| a == "--json"); diff --git a/src/main.rs b/src/main.rs index 9af4035..05ea1e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,6 +76,8 @@ fn execute_request(request: PluginRequest) -> CommandResult { depth: request.options.depth, verbose: request.options.verbose, parallel: request.options.parallel, + filtered: request.options.include_filters.is_some() + || request.options.exclude_filters.is_some(), }; meta_project_cli::execute_command( From 470a65af5b3cf39466262dc0586a210d5087e2fd Mon Sep 17 00:00:00 2001 From: gsc Date: Tue, 27 Oct 2026 14:24:17 -0700 Subject: [PATCH 3/5] fix(project): escape unknown subcommands [[tasks/harmony-2793]] --- src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2507ace..22a573c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,7 +94,7 @@ pub fn execute_command( .collect(); return CommandResult::ShowHelp(Some(format!( "unrecognized command '{}'. Use 'meta git update' to sync projects.", - typed.join(" ") + escape(&typed.join(" ")) ))); } @@ -162,7 +162,8 @@ pub fn execute_command( } } _ => CommandResult::ShowHelp(Some(format!( - "unrecognized command '{command}'. Use 'meta git update' to sync projects." + "unrecognized command '{}'. Use 'meta git update' to sync projects.", + escape(command) ))), } } @@ -332,7 +333,8 @@ fn execute_command_recursive( } } _ => CommandResult::ShowHelp(Some(format!( - "unrecognized command '{command}'. Use 'meta git update' to sync projects." + "unrecognized command '{}'. Use 'meta git update' to sync projects.", + escape(command) ))), } } From 94b87071588953bda05bd2c7f9b6c592635c6497 Mon Sep 17 00:00:00 2001 From: gsc Date: Tue, 27 Oct 2026 15:10:21 -0700 Subject: [PATCH 4/5] fix(project): refuse --include/--exclude after the subcommand too [[tasks/harmony-2793]] --- src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 22a573c..b0fbcd9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -106,7 +106,12 @@ pub fn execute_command( // project list/ls handles its own config discovery if command == "project list" || command == "project ls" { // It lists the whole tree, so a filter would be silently ignored - if options.filtered { + let trailing_filter = args.iter().any(|a| { + ["--include", "--exclude", "-i", "-e"].contains(&a.as_str()) + || a.starts_with("--include=") + || a.starts_with("--exclude=") + }); + if options.filtered || trailing_filter { return CommandResult::Error( "meta project list does not take --include/--exclude".to_string(), ); From 096463dda4cbfc86527cde9f6785c8a87f2ad199 Mon Sep 17 00:00:00 2001 From: gsc Date: Tue, 27 Oct 2026 16:04:37 -0700 Subject: [PATCH 5/5] fix(project): refuse attached short filters on project list [[tasks/harmony-2793]] --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b0fbcd9..638f25c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -107,9 +107,9 @@ pub fn execute_command( if command == "project list" || command == "project ls" { // It lists the whole tree, so a filter would be silently ignored let trailing_filter = args.iter().any(|a| { - ["--include", "--exclude", "-i", "-e"].contains(&a.as_str()) - || a.starts_with("--include=") - || a.starts_with("--exclude=") + a.starts_with("--include") + || a.starts_with("--exclude") + || (a.starts_with("-i") || a.starts_with("-e")) && !a.starts_with("--") }); if options.filtered || trailing_filter { return CommandResult::Error(