auths_sdk/ports/git_config.rs
1/// Error type for git configuration operations.
2#[derive(Debug, thiserror::Error)]
3pub enum GitConfigError {
4 /// The git config command failed with the given message.
5 #[error("git config command failed: {0}")]
6 CommandFailed(String),
7}
8
9/// Configures git settings for cryptographic signing.
10///
11/// Args:
12/// * `key` - The git config key (e.g., "gpg.format")
13/// * `value` - The value to set
14///
15/// Usage:
16/// ```ignore
17/// git_config.set("gpg.format", "ssh")?;
18/// ```
19pub trait GitConfigProvider: Send + Sync {
20 /// Set a global git config key to the given value.
21 fn set(&self, key: &str, value: &str) -> Result<(), GitConfigError>;
22
23 /// Remove a git config key. Returns Ok(()) even if the key was not set.
24 fn unset(&self, key: &str) -> Result<(), GitConfigError>;
25
26 /// Read a git config key at this provider's scope. `None` when unset.
27 ///
28 /// Needed so a caller can refuse to clobber a value it did not write —
29 /// `core.hooksPath` in particular, where overwriting a hook manager's path
30 /// (husky, pre-commit, prek) silently disables every hook it installed.
31 fn get(&self, key: &str) -> Result<Option<String>, GitConfigError>;
32}