Define Descr::FS

This commit is contained in:
Brian Picciano 2024-05-29 13:42:37 +02:00
parent 4075b3e2cd
commit 2e8ec9ff86
3 changed files with 39 additions and 1 deletions

View File

@ -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<Self, Self::Err> {
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<std::path::Path> 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::<String>()

View File

@ -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)
}

View File

@ -57,6 +57,9 @@ impl TryFrom<domain::Settings> 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;