Resolve the target path to an absolute path. If the path is relative, it's resolved relative to the current working directory.
(&self)
| 384 | /// If the path is relative, it's resolved relative to the current |
| 385 | /// working directory. |
| 386 | fn resolve_path(&self) -> CliResult<PathBuf> { |
| 387 | // On Windows, Path::is_absolute() returns false for Unix-style "/foo" |
| 388 | // paths (they're drive-relative). Treat a leading '/' as absolute on |
| 389 | // all platforms so cross-platform tests and user input behave the same. |
| 390 | let looks_absolute = |
| 391 | self.path.is_absolute() || self.path.to_string_lossy().starts_with('/'); |
| 392 | let path = if looks_absolute { |
| 393 | self.path.clone() |
| 394 | } else { |
| 395 | let cwd = |
| 396 | std::env::current_dir().map_err(|e| CliError::invalid_path(&self.path, Some(e)))?; |
| 397 | cwd.join(&self.path) |
| 398 | }; |
| 399 | |
| 400 | // Canonicalize if the path exists, otherwise just normalize it |
| 401 | if path.exists() { |
| 402 | path.canonicalize() |
| 403 | .map_err(|e| CliError::invalid_path(&self.path, Some(e))) |
| 404 | } else { |
| 405 | Ok(path) |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | /// Create the .atomicignore file if a kind is specified. |
| 410 | fn create_ignore_file(&self, repo_path: &Path) -> CliResult<bool> { |