pub struct RepoRef { /* private fields */ }Expand description
A validated repository reference: a namespace and a name, and nothing else.
The only ways to obtain one are resolve_repo_path and RepoRef::new,
both of which validate. There is no constructor that takes a string
unchecked outside of [red], which exists to prove the checks bite.
Implementations§
Source§impl RepoRef
impl RepoRef
Sourcepub fn new(namespace: &str, name: &str) -> Result<RepoRef, Error>
pub fn new(namespace: &str, name: &str) -> Result<RepoRef, Error>
Validate a namespace and a repository name and pair them up.
The namespace may itself be nested (team/sub); every level is validated
by the same rules as the repository name.
Sourcepub fn key(&self) -> String
pub fn key(&self) -> String
The catalog key, <namespace>/<repo>. Stable, and the only identifier
the catalog stores.
Sourcepub fn to_ssh_path(&self) -> String
pub fn to_ssh_path(&self) -> String
The path as a client would write it after the colon:
<namespace>/<repo>.git.
Sourcepub fn path_under(&self, root: &Path) -> Result<PathBuf, Error>
pub fn path_under(&self, root: &Path) -> Result<PathBuf, Error>
Where this repository’s directory lives under root, checked against
symlink escapes.
The string checks in resolve_repo_path cannot see a symlink: ns may
be a perfectly ordinary-looking name that happens to be a link to /etc.
So the deepest existing ancestor of the target is canonicalised and
asserted to still be inside the canonicalised root.
This is for the fs backend only. The appliance has no filesystem and
never calls it.