diff --git a/src/origin/descr.rs b/src/origin/descr.rs index 9610bd6..02a9510 100644 --- a/src/origin/descr.rs +++ b/src/origin/descr.rs @@ -33,6 +33,28 @@ impl std::fmt::Display for GitUrl { } } +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct FSPath(std::path::PathBuf); + +impl std::str::FromStr for FSPath { + type Err = std::convert::Infallible; + fn from_str(s: &str) -> Result { + Ok(FSPath(s.parse().unwrap())) + } +} + +impl std::fmt::Display for FSPath { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.display().fmt(f) + } +} + +impl std::convert::AsRef for FSPath { + fn as_ref(&self) -> &std::path::Path { + self.0.as_path() + } +} + #[serde_as] #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(tag = "kind")] @@ -44,6 +66,12 @@ pub enum Descr { url: GitUrl, branch_name: String, }, + + #[serde(rename = "fs")] + FS { + #[serde_as(as = "DisplayFromStr")] + path: FSPath, + }, } impl Descr { @@ -62,6 +90,10 @@ impl Descr { h_update(url.parsed.to_string().as_str()); h_update(branch_name); } + Descr::FS { path } => { + h_update("git"); + h_update(path.to_string().as_str()); + } } h.finalize().encode_hex::() diff --git a/src/origin/git.rs b/src/origin/git.rs index 87a037f..c1a0363 100644 --- a/src/origin/git.rs +++ b/src/origin/git.rs @@ -41,7 +41,10 @@ impl Proxy { let origin::Descr::Git { ref url, ref branch_name, - } = descr; + } = descr + else { + panic!("cannot deconstruct {descr:?} to GitUrl") + }; (url, branch_name) } diff --git a/src/service/http/util.rs b/src/service/http/util.rs index 1b30e81..9b34254 100644 --- a/src/service/http/util.rs +++ b/src/service/http/util.rs @@ -57,6 +57,9 @@ impl TryFrom for UrlEncodedDomainSettings { res.domain_setting_origin_descr_git_url = Some(url); res.domain_setting_origin_descr_git_branch_name = Some(branch_name); } + origin::Descr::FS { .. } => { + return Err(unexpected::Error::from("Descr::FS not supported")) + } } res.domain_setting_add_path_prefix = v.add_path_prefix;