Load the user's default identity from the identity store. Looks for `~/.atomic/identities/config.toml` to find the default identity, then loads its `identity.toml` for name/email/public key. Returns `None` if: - The identity store directory doesn't exist - No default identity is configured - The default identity's files can't be read
(override_dir: Option<&Path>)
| 341 | /// - No default identity is configured |
| 342 | /// - The default identity's files can't be read |
| 343 | fn load_default_user_identity(override_dir: Option<&Path>) -> Option<UserIdentityInfo> { |
| 344 | let identities_dir = match override_dir { |
| 345 | Some(dir) => dir.to_path_buf(), |
| 346 | None => default_identities_dir()?, |
| 347 | }; |
| 348 | |
| 349 | if !identities_dir.is_dir() { |
| 350 | return None; |
| 351 | } |
| 352 | |
| 353 | // Read config.toml to find the default identity |
| 354 | let config_path = identities_dir.join("config.toml"); |
| 355 | let config_content = std::fs::read_to_string(&config_path).ok()?; |
| 356 | |
| 357 | // Parse the config to find the default identity directory name |
| 358 | let default_id = extract_default_identity_from_config(&config_content)?; |
| 359 | |
| 360 | // Try to find the identity directory |
| 361 | // The store uses {name}-{usage}-{id_short} as directory names, |
| 362 | // but we can also match by the ID directly |
| 363 | load_identity_by_id(&identities_dir, &default_id) |
| 364 | .or_else(|| load_identity_by_scanning(&identities_dir, &default_id)) |
| 365 | } |
| 366 | |
| 367 | /// Get the default identities directory: `~/.atomic/identities/` |
| 368 | fn default_identities_dir() -> Option<PathBuf> { |
no test coverage detected