Skip to main content

expected_path

Function expected_path 

Source
pub fn expected_path(container: &Path, branch: &BranchName) -> Result<PathBuf>
Expand description

Where the worktree of branch belongs: the branch’s components under the container.

Proved on every call, lexically and without touching the filesystem, to be strictly below the container: every component of the result after the container’s own is a normal component, so the path cannot escape, cannot be the container itself, and cannot carry . or ...

use majordomus_cli::worktree::{expected_path, BranchName};
use std::path::{Path, PathBuf};
let root = Path::new("/a/foo-wt");
let b = BranchName::parse("feature/providers/openai-streaming").unwrap();
assert_eq!(expected_path(root, &b).unwrap(), PathBuf::from("/a/foo-wt/feature/providers/openai-streaming"));