MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / resolve_path_with_discovery

Function resolve_path_with_discovery

src/config.rs:705–714  ·  view source on GitHub ↗

Like [`resolve_path`], but when `path` is `None` it walks up from `cwd` to find the nearest initialised `TraceDecay` project before falling back to `cwd` itself. Used by `serve`, `sync`, and `status`. NOT used by `init` (which must create a fresh project at the target directory).

(path: Option<String>)

Source from the content-addressed store, hash-verified

703/// Used by `serve`, `sync`, and `status`. NOT used by `init` (which must
704/// create a fresh project at the target directory).
705pub fn resolve_path_with_discovery(path: Option<String>) -> PathBuf {
706 if let Some(p) = path {
707 PathBuf::from(p)
708 } else {
709 let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
710 discover_project_root(&cwd)
711 .or_else(|| crate::worktree::git_worktree_root(&cwd))
712 .unwrap_or(cwd)
713 }
714}
715
716fn paths_same(left: &Path, right: &Path) -> bool {
717 let left = std::fs::canonicalize(left).unwrap_or_else(|_| left.to_path_buf());

Callers 7

resolve_cli_project_rootFunction · 0.85
dispatch_commandFunction · 0.85
project_scopedMethod · 0.85
resolve_serve_startupFunction · 0.85
handle_memory_actionFunction · 0.85
handle_syncFunction · 0.85

Calls 2

discover_project_rootFunction · 0.85
git_worktree_rootFunction · 0.85

Tested by

no test coverage detected