diff --git a/src/clone_queue.rs b/src/clone_queue.rs index 90cefe1..38812fb 100644 --- a/src/clone_queue.rs +++ b/src/clone_queue.rs @@ -82,7 +82,7 @@ impl CloneQueue { true } - /// Add multiple tasks from a .meta file + /// Add multiple tasks from a .meta.yaml file pub fn push_from_meta(&self, base_dir: &Path, depth_level: usize) -> anyhow::Result { // Check meta depth limit if let Some(max_depth) = self.meta_depth { @@ -95,8 +95,8 @@ impl CloneQueue { } } - let Some((meta_path, _format)) = config::find_meta_config_in(base_dir)? else { - debug!("No .meta config found in {}", escape_path(base_dir)); + let Some(meta_path) = config::find_meta_config_in(base_dir)? else { + debug!("No .meta.yaml found in {}", escape_path(base_dir)); return Ok(0); }; @@ -178,7 +178,7 @@ impl CloneQueue { self.git_depth.as_deref() } - /// Mark a task as completed and check for nested .meta files + /// Mark a task as completed and check for nested .meta.yaml files pub fn mark_completed(&self, task: &CloneTask) -> anyhow::Result { self.total_completed.fetch_add(1, Ordering::SeqCst); @@ -187,17 +187,17 @@ impl CloneQueue { completed.insert(task.target_path.clone()); } - // Check for nested .meta file and add children to queue + // Check for nested .meta.yaml file and add children to queue let added = self.push_from_meta(&task.target_path, task.depth_level + 1)?; debug!( "mark_completed: {} -> {} nested tasks discovered", task.name, added ); - // Warn if the config declared meta: true but no nested .meta was found + // Warn if the config declared meta: true but no nested .meta.yaml was found if task.is_meta && added == 0 { warn!( - "'{}' is declared with `meta: true` but no .meta config was found inside it", + "'{}' is declared with `meta: true` but no .meta.yaml was found inside it", task.name ); } @@ -263,16 +263,16 @@ mod tests { #[cfg(unix)] #[test] fn push_from_meta_does_not_look_past_the_depth_limit() { - // child exists with a dangling .meta; at depth limit 0 it is never + // child exists with a dangling .meta.yaml; at depth limit 0 it is never // read, so seeding still queues the missing sibling let dir = tempfile::tempdir().unwrap(); std::fs::create_dir(dir.path().join("child")).unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{"projects": {"child": {"repo": "u", "meta": true}, "sib": "u2"}}"#, ) .unwrap(); - std::os::unix::fs::symlink("missing.json", dir.path().join("child/.meta")).unwrap(); + std::os::unix::fs::symlink("missing.yaml", dir.path().join("child/.meta.yaml")).unwrap(); let queue = CloneQueue::new(None, Some(0)); assert_eq!(queue.push_from_meta(dir.path(), 0).unwrap(), 1); } @@ -280,16 +280,16 @@ mod tests { #[cfg(unix)] #[test] fn push_from_meta_fails_on_a_nested_config_it_cannot_read() { - // child/.meta is a link to nowhere: its repos are unknown, which is + // child/.meta.yaml is a link to nowhere: its repos are unknown, which is // an error, not "no nested repos" let dir = tempfile::tempdir().unwrap(); std::fs::create_dir(dir.path().join("child")).unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{"projects": {"child": {"repo": "u", "meta": true}}}"#, ) .unwrap(); - std::os::unix::fs::symlink("missing.json", dir.path().join("child/.meta")).unwrap(); + std::os::unix::fs::symlink("missing.yaml", dir.path().join("child/.meta.yaml")).unwrap(); let queue = CloneQueue::new(None, None); let err = queue.push_from_meta(dir.path(), 0).unwrap_err(); assert!(format!("{err:#}").contains("Cannot read"), "{err:#}"); @@ -388,7 +388,7 @@ mod tests { fn push_from_meta_discovers_projects() { let dir = tempfile::tempdir().unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{"projects": { "alpha": "git@github.com:org/alpha.git", "beta": "git@github.com:org/beta.git" @@ -414,7 +414,7 @@ mod tests { fn push_from_meta_respects_depth_limit() { let dir = tempfile::tempdir().unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{"projects": {"repo": "git@github.com:org/repo.git"}}"#, ) .unwrap(); @@ -435,7 +435,7 @@ mod tests { // Create the project directory so it appears "already cloned" std::fs::create_dir(dir.path().join("existing")).unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{"projects": {"existing": "git@github.com:org/existing.git"}}"#, ) .unwrap(); @@ -449,7 +449,7 @@ mod tests { fn push_from_meta_skips_projects_without_repo() { let dir = tempfile::tempdir().unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{"projects": {"no-repo": {"path": "no-repo"}}}"#, ) .unwrap(); @@ -463,7 +463,7 @@ mod tests { fn push_from_meta_preserves_is_meta_flag() { let dir = tempfile::tempdir().unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{"projects": { "nested": {"repo": "git@github.com:org/nested.git", "meta": true}, "plain": "git@github.com:org/plain.git" @@ -490,9 +490,9 @@ mod tests { let child_dir = dir.path().join("child"); std::fs::create_dir(&child_dir).unwrap(); - // Child has its own .meta with a grandchild + // Child has its own .meta.yaml with a grandchild std::fs::write( - child_dir.join(".meta"), + child_dir.join(".meta.yaml"), r#"{"projects": {"grandchild": "git@github.com:org/grandchild.git"}}"#, ) .unwrap(); @@ -516,7 +516,7 @@ mod tests { let dir = tempfile::tempdir().unwrap(); let child_dir = dir.path().join("child"); std::fs::create_dir(&child_dir).unwrap(); - // No .meta inside child + // No .meta.yaml inside child let queue = CloneQueue::new(None, None); let task = CloneTask { diff --git a/src/worktree/helpers.rs b/src/worktree/helpers.rs index a67321b..f9bd935 100644 --- a/src/worktree/helpers.rs +++ b/src/worktree/helpers.rs @@ -1,7 +1,6 @@ //! Utility functions for worktree management. use anyhow::{Context, Result}; -use meta_core::config::ConfigFormat; use meta_core::display::{escape, escape_path}; use std::path::{Path, PathBuf}; @@ -32,14 +31,14 @@ pub fn resolve_worktree_root(meta_dir: Option<&Path>) -> Result { if let Ok(env_path) = std::env::var("META_WORKTREES") { return Ok(PathBuf::from(env_path)); } - // 2. Check worktrees_dir in .meta config. In a worktree set, of the + // 2. Check worktrees_dir in .meta.yaml. In a worktree set, of the // checkout it stands for: its sets live where that one's do if let Some(dir) = meta_dir.map(owner_dir) { let dir = dir.as_path(); // The config's rules for the worktree directory (inside the // workspace, not inside a project, not into .git) hold here too, // whoever ran this plugin - if let Some((config, _)) = meta_core::config::find_meta_config_in(dir)? { + if let Some(config) = meta_core::config::find_meta_config_in(dir)? { meta_core::config::parse_meta_config(&config)?; } if let Some(configured) = read_worktrees_dir_from_config(dir)? { @@ -47,7 +46,7 @@ pub fn resolve_worktree_root(meta_dir: Option<&Path>) -> Result { // may not point it outside the workspace let relative = meta_core::config::relative_dir(dir, &configured).map_err(|why| { anyhow::anyhow!( - "Invalid worktrees_dir in the .meta of {}: {why} (use META_WORKTREES \ + "Invalid worktrees_dir in the .meta.yaml of {}: {why} (use META_WORKTREES \ for a directory elsewhere)", escape_path(dir) ) @@ -75,18 +74,14 @@ pub fn resolve_worktree_root(meta_dir: Option<&Path>) -> Result { /// [`meta_core::config::find_meta_config_in`]) as a JSON value, if there is /// one. One that can't be read or parsed is an error. pub fn read_meta_config_value(meta_dir: &Path) -> Result> { - let Some((path, format)) = meta_core::config::find_meta_config_in(meta_dir)? else { + let Some(path) = meta_core::config::find_meta_config_in(meta_dir)? else { return Ok(None); }; let content = std::fs::read_to_string(&path) .with_context(|| format!("Cannot read {}", escape_path(&path)))?; - let value = match format { - ConfigFormat::Json => serde_json::from_str(&content).map_err(anyhow::Error::from), - ConfigFormat::Yaml => serde_yaml_ng::from_str::(&content) - .map_err(anyhow::Error::from) - .and_then(|v| serde_json::to_value(v).map_err(anyhow::Error::from)), - }; - value + serde_yaml_ng::from_str::(&content) + .map_err(anyhow::Error::from) + .and_then(|v| serde_json::to_value(v).map_err(anyhow::Error::from)) .map(Some) .with_context(|| format!("Cannot parse {}", escape_path(&path))) } @@ -105,7 +100,7 @@ pub fn find_meta_dir() -> Option { pub fn require_meta_dir() -> Result { let cwd = std::env::current_dir()?; meta_core::config::nearest_meta_dir(&cwd)? - .ok_or_else(|| anyhow::anyhow!("Not inside a meta project (no .meta found)")) + .ok_or_else(|| anyhow::anyhow!("Not inside a meta project (no .meta.yaml found)")) } /// The directory of the worktree set `name` under `worktree_root`. A symlink @@ -177,10 +172,10 @@ pub fn discover_and_validate_worktree( Ok(repos) } -/// Load and parse the .meta config, returning the project list. +/// Load and parse the .meta.yaml, returning the project list. pub fn load_projects(meta_dir: &Path) -> Result> { - let (config_path, _) = meta_core::config::find_meta_config(meta_dir, None)? - .ok_or_else(|| anyhow::anyhow!("No .meta config found in {}", escape_path(meta_dir)))?; + let config_path = meta_core::config::find_meta_config(meta_dir, None)? + .ok_or_else(|| anyhow::anyhow!("No .meta.yaml found in {}", escape_path(meta_dir)))?; let (projects, _) = meta_core::config::parse_meta_config(&config_path)?; Ok(projects) } @@ -287,7 +282,7 @@ pub fn dest_in_set(wt_dir: &Path, place: &str) -> Result { /// Look up a project by alias, supporting nested paths like "vendor/tree-sitter-markdown". /// -/// For simple aliases (no `/`), uses flat lookup from the current .meta. +/// For simple aliases (no `/`), uses flat lookup from the current .meta.yaml. /// For nested paths, walks the meta tree recursively to find the project. /// /// Returns the resolved path and project info. @@ -617,7 +612,7 @@ mod tests { let tmp = tempfile::tempdir().unwrap(); std::fs::write( - tmp.path().join(".meta"), + tmp.path().join(".meta.yaml"), r#"{"projects": {"vendor": {"repo": "git@github.com:org/vendor.git", "meta": true}}}"#, ) .unwrap(); @@ -857,7 +852,7 @@ mod tests { fn lookup_nested_simple_alias_works() { let tmp = tempfile::tempdir().unwrap(); std::fs::write( - tmp.path().join(".meta"), + tmp.path().join(".meta.yaml"), r#"{"projects": {"backend": "git@github.com:org/backend.git"}}"#, ) .unwrap(); @@ -875,16 +870,16 @@ mod tests { let nested = vendor.join("nested-lib"); std::fs::create_dir_all(&nested).unwrap(); - // Root .meta - vendor is a nested meta repo (has repo URL + meta: true) + // Root .meta.yaml - vendor is a nested meta repo (has repo URL + meta: true) std::fs::write( - tmp.path().join(".meta"), + tmp.path().join(".meta.yaml"), r#"{"projects": {"vendor": {"repo": "git@github.com:org/vendor.git", "meta": true}}}"#, ) .unwrap(); - // Nested .meta inside vendor (simulates what exists after cloning vendor) + // Nested .meta.yaml inside vendor (simulates what exists after cloning vendor) std::fs::write( - vendor.join(".meta"), + vendor.join(".meta.yaml"), r#"{"projects": {"nested-lib": "git@github.com:org/nested-lib.git"}}"#, ) .unwrap(); @@ -900,7 +895,7 @@ mod tests { std::fs::create_dir(tmp.path().join("vendor")).unwrap(); std::fs::write( - tmp.path().join(".meta"), + tmp.path().join(".meta.yaml"), r#"{"projects": {"vendor": {"repo": "git@github.com:org/vendor.git", "meta": true}}}"#, ) .unwrap(); @@ -916,7 +911,7 @@ mod tests { fn lookup_nested_unknown_simple_alias_fails() { let tmp = tempfile::tempdir().unwrap(); std::fs::write( - tmp.path().join(".meta"), + tmp.path().join(".meta.yaml"), r#"{"projects": {"backend": "git@github.com:org/backend.git"}}"#, ) .unwrap(); @@ -937,12 +932,12 @@ mod tests { std::fs::create_dir_all(&nested).unwrap(); std::fs::write( - tmp.path().join(".meta"), + tmp.path().join(".meta.yaml"), r#"{"projects": {"vendor": {"repo": "git@github.com:org/vendor.git", "meta": true}}}"#, ) .unwrap(); std::fs::write( - vendor.join(".meta"), + vendor.join(".meta.yaml"), r#"{"projects": {"lib": "git@github.com:org/lib.git"}}"#, ) .unwrap(); @@ -970,16 +965,16 @@ mod tests { let custom_path = vendor.join("packages/mylib"); std::fs::create_dir_all(&custom_path).unwrap(); - // Root .meta - vendor is a nested meta repo + // Root .meta.yaml - vendor is a nested meta repo std::fs::write( - tmp.path().join(".meta"), + tmp.path().join(".meta.yaml"), r#"{"projects": {"vendor": {"repo": "git@github.com:org/vendor.git", "meta": true}}}"#, ) .unwrap(); - // Nested .meta with custom path + // Nested .meta.yaml with custom path std::fs::write( - vendor.join(".meta"), + vendor.join(".meta.yaml"), r#"{"projects": {"mylib": {"repo": "git@github.com:org/mylib.git", "path": "packages/mylib"}}}"#, ) .unwrap(); @@ -1001,21 +996,21 @@ mod tests { // Root tracks vendor std::fs::write( - tmp.path().join(".meta"), + tmp.path().join(".meta.yaml"), r#"{"projects": {"vendor": {"repo": "git@github.com:org/vendor.git", "meta": true}}}"#, ) .unwrap(); // Vendor tracks sub-vendor std::fs::write( - vendor.join(".meta"), + vendor.join(".meta.yaml"), r#"{"projects": {"sub-vendor": {"repo": "git@github.com:org/sub-vendor.git", "meta": true}}}"#, ) .unwrap(); // Sub-vendor tracks deep-lib std::fs::write( - sub_vendor.join(".meta"), + sub_vendor.join(".meta.yaml"), r#"{"projects": {"deep-lib": "git@github.com:org/deep-lib.git"}}"#, ) .unwrap(); diff --git a/src/worktree/hooks.rs b/src/worktree/hooks.rs index da1465f..2cd6e57 100644 --- a/src/worktree/hooks.rs +++ b/src/worktree/hooks.rs @@ -7,9 +7,9 @@ use std::process::{Command, Stdio}; use super::helpers::read_meta_config_value; use super::types::{CreateRepoEntry, PruneEntry}; -/// Fire a worktree lifecycle hook if configured in `.meta`. +/// Fire a worktree lifecycle hook if configured in `.meta.yaml`. /// -/// Reads the `.meta` config for `worktree.hooks.`. +/// Reads the `.meta.yaml` config for `worktree.hooks.`. /// If configured, spawns the command and pipes `payload` JSON to stdin. /// The hook's stderr goes to meta's stderr, as git does for its hooks; a /// pipe that nobody reads would block a verbose hook forever. diff --git a/src/worktree/workspace.rs b/src/worktree/workspace.rs index 422509a..a926cc6 100644 --- a/src/worktree/workspace.rs +++ b/src/worktree/workspace.rs @@ -16,7 +16,7 @@ use super::safety::{relative_label, RemovalCheck}; pub struct Workspace { pub root: PathBuf, /// The git directory of each repository (the root's own, then every one - /// in its `.meta` tree, nested ones included): where the records of the + /// in its `.meta.yaml` tree, nested ones included): where the records of the /// worktrees made from it are. pub repos: Vec, /// What couldn't be read (the project tree, a repository), with why: