2024-05-15 07:55:05 +01:00
|
|
|
use std::path::PathBuf;
|
2024-05-11 19:46:20 +01:00
|
|
|
|
2024-05-15 07:55:05 +01:00
|
|
|
#[derive(
|
2024-05-19 20:02:06 +01:00
|
|
|
Clone,
|
|
|
|
Default,
|
|
|
|
Debug,
|
|
|
|
Hash,
|
|
|
|
PartialEq,
|
|
|
|
Eq,
|
|
|
|
serde::Deserialize,
|
|
|
|
derive_more::Deref,
|
|
|
|
derive_more::From,
|
2024-05-15 07:55:05 +01:00
|
|
|
)]
|
2024-05-11 19:46:20 +01:00
|
|
|
pub struct GitDir(PathBuf);
|
|
|
|
impl GitDir {
|
|
|
|
pub fn new(pathbuf: &std::path::Path) -> Self {
|
|
|
|
Self(pathbuf.to_path_buf())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub const fn pathbuf(&self) -> &PathBuf {
|
|
|
|
&self.0
|
|
|
|
}
|
2024-06-07 20:01:29 +01:00
|
|
|
|
|
|
|
pub fn into_string(self) -> String {
|
|
|
|
self.to_string()
|
|
|
|
}
|
2024-05-11 19:46:20 +01:00
|
|
|
}
|
|
|
|
impl std::fmt::Display for GitDir {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
write!(f, "{}", &self.0.display())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl From<&str> for GitDir {
|
|
|
|
fn from(value: &str) -> Self {
|
|
|
|
Self(value.into())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl From<&GitDir> for PathBuf {
|
|
|
|
fn from(value: &GitDir) -> Self {
|
|
|
|
value.to_path_buf()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl From<GitDir> for PathBuf {
|
|
|
|
fn from(value: GitDir) -> Self {
|
|
|
|
value.0
|
|
|
|
}
|
|
|
|
}
|