Paul Campbell
9c20e780d0
All checks were successful
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Rust / build (push) Successful in 1m34s
Closes kemitix/git-next#100
67 lines
1.4 KiB
Rust
67 lines
1.4 KiB
Rust
//
|
|
use std::path::PathBuf;
|
|
|
|
use derive_more::Deref;
|
|
use pike::pike;
|
|
|
|
/// 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,
|
|
}
|
|
impl GitDir {
|
|
pub const fn pathbuf(&self) -> &PathBuf {
|
|
&self.pathbuf
|
|
}
|
|
pub const fn storage_path_type(&self) -> StoragePathType {
|
|
self.storage_path_type
|
|
}
|
|
pub fn as_fs(&self) -> kxio::fs::FileSystem {
|
|
pike! {
|
|
self
|
|
|> Self::pathbuf
|
|
|> PathBuf::clone
|
|
|> kxio::fs::new
|
|
}
|
|
}
|
|
}
|
|
impl std::fmt::Display for GitDir {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "{}", &self.pathbuf.display())
|
|
}
|
|
}
|
|
impl Deref for GitDir {
|
|
type Target = PathBuf;
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.pathbuf
|
|
}
|
|
}
|
|
impl From<&GitDir> for PathBuf {
|
|
fn from(value: &GitDir) -> Self {
|
|
value.to_path_buf()
|
|
}
|
|
}
|
|
impl From<&GitDir> for kxio::fs::FileSystem {
|
|
fn from(gitdir: &GitDir) -> Self {
|
|
gitdir.as_fs()
|
|
}
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
|
pub enum StoragePathType {
|
|
Internal,
|
|
External,
|
|
}
|