Resolve the vault half of the policy for one live colocated Git repository (RFC §6.2: "`.vault/` is private by default but may be tracked under explicit policy"). An explicit `[git.shim] vault` record in the repository configuration wins in both directions — the first import records the detected value, and a user override is honored. A configuration that predates the field omits it: that is "unde
(git: &git2::Repository)
| 281 | /// fault — it propagates instead of silently changing the resolved |
| 282 | /// policy. |
| 283 | pub fn resolve_for_git(git: &git2::Repository) -> Result<Self, ProjectTreeError> { |
| 284 | if let Some(workdir) = git.workdir() { |
| 285 | let repository_present = workdir.join(".atomic").exists(); |
| 286 | let dot_dir = if repository_present { |
| 287 | Repository::canonical_dot_dir(workdir).map_err(|error| { |
| 288 | ProjectTreeError::Repository(format!( |
| 289 | "cannot resolve the Atomic directory for the checkout at {}: {error}", |
| 290 | workdir.display() |
| 291 | )) |
| 292 | })? |
| 293 | } else { |
| 294 | // No local `.atomic`: nothing is recorded yet (a fresh |
| 295 | // checkout before its first import, or a plain Git |
| 296 | // repository) — the HEAD tree decides. |
| 297 | match Repository::canonical_dot_dir(workdir) { |
| 298 | Ok(dot_dir) => dot_dir, |
| 299 | Err(_) => return Ok(Self::from_git_head(git)), |
| 300 | } |
| 301 | }; |
| 302 | let config_path = dot_dir.join("config.toml"); |
| 303 | if config_path.exists() { |
| 304 | let (config, _) = atomic_config::RepoConfig::load_with_vault_recorded(&config_path) |
| 305 | .map_err(|error| { |
| 306 | ProjectTreeError::Repository(format!( |
| 307 | "cannot load the repository configuration at {}: {error}", |
| 308 | config_path.display() |
| 309 | )) |
| 310 | })?; |
| 311 | if let Some(vault) = config.git.shim.vault { |
| 312 | return Ok(match vault { |
| 313 | atomic_config::ShimVaultPolicy::Tracked => Self::IncludeVault, |
| 314 | atomic_config::ShimVaultPolicy::Private => Self::ShimPrivate, |
| 315 | }); |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | Ok(Self::from_git_head(git)) |
| 320 | } |
| 321 | |
| 322 | /// Auto-detect from the Git HEAD tree: does the tracked root tree hold |
| 323 | /// a `.vault` entry? An unborn or detached-without-commit HEAD reads |
nothing calls this directly
no test coverage detected