Skip to content

Commit

Permalink
Add a notional kind to Repo model
Browse files Browse the repository at this point in the history
  • Loading branch information
bierbaum committed Nov 16, 2022
1 parent 0110a47 commit b7329d4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions focus/internals/src/lib/model/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ pub const PROJECT_CACHE_INCLUDE_HEADERS_FILE_CONFIG_KEY: &str =
"focus.project-cache.include-headers-from";
pub const BAZEL_ONE_SHOT_RESOLUTION_CONFIG_KEY: &str = "focus.bazel.one-shot";

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum WorkingTreeKind {
Sparse,
Dense,
}

/// Models a Git working tree.
pub struct WorkingTree {
repo: git2::Repository,
Expand Down Expand Up @@ -110,6 +116,14 @@ impl WorkingTree {
Self::new(repo)
}

pub fn kind(&self) -> WorkingTreeKind {
if self.sparse_checkout_path().is_file() {
WorkingTreeKind::Sparse
} else {
WorkingTreeKind::Dense
}
}

fn info_dir(&self) -> PathBuf {
self.repo.path().join("info")
}
Expand Down

0 comments on commit b7329d4

Please sign in to comment.