MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_path

Method resolve_path

atomic-cli/src/commands/init.rs:411–432  ·  view source on GitHub ↗

Resolve the target path to an absolute path. If the path is relative, it's resolved relative to the current working directory.

(&self)

Source from the content-addressed store, hash-verified

409 /// If the path is relative, it's resolved relative to the current
410 /// working directory.
411 fn resolve_path(&self) -> CliResult<PathBuf> {
412 // On Windows, Path::is_absolute() returns false for Unix-style "/foo"
413 // paths (they're drive-relative). Treat a leading '/' as absolute on
414 // all platforms so cross-platform tests and user input behave the same.
415 let looks_absolute =
416 self.path.is_absolute() || self.path.to_string_lossy().starts_with('/');
417 let path = if looks_absolute {
418 self.path.clone()
419 } else {
420 let cwd =
421 std::env::current_dir().map_err(|e| CliError::invalid_path(&self.path, Some(e)))?;
422 cwd.join(&self.path)
423 };
424
425 // Canonicalize if the path exists, otherwise just normalize it
426 if path.exists() {
427 path.canonicalize()
428 .map_err(|e| CliError::invalid_path(&self.path, Some(e)))
429 } else {
430 Ok(path)
431 }
432 }
433
434 /// Create the .atomicignore file if a kind is specified.
435 fn create_ignore_file(&self, repo_path: &Path) -> CliResult<bool> {

Callers 4

runMethod · 0.45
test_resolve_path_dotFunction · 0.45

Calls 3

canonicalizeMethod · 0.80
cloneMethod · 0.45
existsMethod · 0.45

Tested by 3

test_resolve_path_dotFunction · 0.36