use std::path::Path;
use std::sync::Arc;
use crate::repo::{IngestedRepo, RepoSource, SnapshotBackend};
#[derive(Clone, Debug)]
pub struct WorkspaceHandle {
inner: Arc<IngestedRepo>,
}
impl WorkspaceHandle {
pub fn new(ingested: IngestedRepo) -> Self {
Self { inner: Arc::new(ingested) }
}
#[cfg(any(test, feature = "test-util"))]
pub fn for_local_path_test(
name: impl Into<String>,
path: impl Into<std::path::PathBuf>,
) -> Self {
let path: std::path::PathBuf = path.into();
let ingested = IngestedRepo {
name: name.into(),
workspace: path.clone(),
source: RepoSource::LocalPath { path },
snapshot_backend: None,
on_disk_git_remote: None,
cleanup: None,
};
Self::new(ingested)
}
pub fn name(&self) -> &str {
&self.inner.name
}
pub fn workspace(&self) -> &Path {
&self.inner.workspace
}
pub fn source(&self) -> &RepoSource {
&self.inner.source
}
pub fn snapshot_backend(&self) -> Option<SnapshotBackend> {
self.inner.snapshot_backend
}
pub fn on_disk_git_remote(&self) -> Option<&str> {
self.inner.on_disk_git_remote.as_deref()
}
}