Process a single target configuration
(
&self,
agent_name: &str,
target: &TargetConfig,
options: &SyncOptions,
)
| 445 | |
| 446 | /// Process a single target configuration |
| 447 | fn process_target( |
| 448 | &self, |
| 449 | agent_name: &str, |
| 450 | target: &TargetConfig, |
| 451 | options: &SyncOptions, |
| 452 | ) -> Result<SyncResult> { |
| 453 | let source = self.source_dir.join(&target.source); |
| 454 | |
| 455 | match target.sync_type { |
| 456 | SyncType::Symlink => { |
| 457 | let dest = self.ensure_safe_destination(&target.destination)?; |
| 458 | self.revalidate_path(&source)?; // SECURITY: Validate source |
| 459 | let resolved = self.resolve_source_path(&source, target, options)?; |
| 460 | self.create_symlink(&resolved, &dest, options) |
| 461 | } |
| 462 | SyncType::SymlinkContents => { |
| 463 | let dest = self.ensure_safe_destination(&target.destination)?; |
| 464 | self.revalidate_path(&source)?; // SECURITY: Validate source |
| 465 | self.create_symlinks_for_contents( |
| 466 | &source, |
| 467 | &dest, |
| 468 | target.pattern.as_deref(), |
| 469 | target, |
| 470 | options, |
| 471 | ) |
| 472 | } |
| 473 | SyncType::NestedGlob => { |
| 474 | let _ = self.ensure_safe_destination(&target.destination)?; |
| 475 | let search_root = self.project_root.join(&target.source); |
| 476 | self.revalidate_path(&search_root).with_context(|| { |
| 477 | format!( |
| 478 | "NestedGlob source resolves outside project root: {}", |
| 479 | target.source |
| 480 | ) |
| 481 | })?; |
| 482 | |
| 483 | self.process_nested_glob( |
| 484 | &search_root, |
| 485 | target.pattern.as_deref().unwrap_or("**/AGENTS.md"), |
| 486 | &target.exclude, |
| 487 | &target.destination, |
| 488 | options, |
| 489 | ) |
| 490 | } |
| 491 | SyncType::ModuleMap => self.process_module_map(agent_name, target, options), |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | fn resolve_source_path( |
| 496 | &self, |
no test coverage detected