2024-06-16 08:00:43 +01:00
|
|
|
//
|
2024-05-15 07:55:05 +01:00
|
|
|
use std::path::PathBuf;
|
2024-05-11 19:46:20 +01:00
|
|
|
|
2024-07-06 14:25:43 +01:00
|
|
|
use derive_more::Deref;
|
|
|
|
|
|
|
|
/// The path to the directory containing the git repository.
|
|
|
|
#[derive(
|
|
|
|
Clone,
|
|
|
|
Debug,
|
|
|
|
derive_more::From,
|
|
|
|
PartialEq,
|
|
|
|
Eq,
|
|
|
|
PartialOrd,
|
|
|
|
Ord,
|
|
|
|
derive_more::AsRef,
|
|
|
|
derive_more::Constructor,
|
|
|
|
)]
|
|
|
|
pub struct GitDir {
|
|
|
|
pathbuf: PathBuf,
|
|
|
|
/// Whether the directory is under the control of git-next (Internal) or not (External).
|
|
|
|
storage_path_type: StoragePathType,
|
|
|
|
}
|
2024-05-11 19:46:20 +01:00
|
|
|
impl GitDir {
|
|
|
|
pub const fn pathbuf(&self) -> &PathBuf {
|
2024-07-06 14:25:43 +01:00
|
|
|
&self.pathbuf
|
|
|
|
}
|
|
|
|
pub const fn storage_path_type(&self) -> &StoragePathType {
|
|
|
|
&self.storage_path_type
|
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 {
|
2024-07-06 14:25:43 +01:00
|
|
|
write!(f, "{}", &self.pathbuf.display())
|
2024-05-11 19:46:20 +01:00
|
|
|
}
|
|
|
|
}
|
2024-07-06 14:25:43 +01:00
|
|
|
impl Deref for GitDir {
|
|
|
|
type Target = PathBuf;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
&self.pathbuf
|
2024-05-11 19:46:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
impl From<&GitDir> for PathBuf {
|
|
|
|
fn from(value: &GitDir) -> Self {
|
|
|
|
value.to_path_buf()
|
|
|
|
}
|
|
|
|
}
|
2024-07-06 14:25:43 +01:00
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
|
|
|
pub enum StoragePathType {
|
|
|
|
Internal,
|
|
|
|
External,
|
|
|
|
}
|