From 09c3ae91830bd9c7543b401b19f8c65a15205d32 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 5 Mar 2026 15:03:37 +0000 Subject: fix(whoami): detect and fall back to system git config for nostr login Add GitSystem to SignerInfoSource so credentials stored in the system git config (/etc/gitconfig) are included in the priority fallback chain (local > global > system) and shown as a separate level in whoami output. --- src/lib/git/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/lib/git/mod.rs') diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs index 23fa5f0..ca7aa3f 100644 --- a/src/lib/git/mod.rs +++ b/src/lib/git/mod.rs @@ -1089,6 +1089,22 @@ pub fn get_git_config_item(git_repo: &Option<&Repo>, item: &str) -> Result Result> { + let config = git2::Config::open_default().context("failed to open git config")?; + // Try system level first, then ProgramData (Windows equivalent) + for level in [git2::ConfigLevel::System, git2::ConfigLevel::ProgramData] { + if let Ok(level_config) = config.open_level(level) { + match level_config.get_entry(item) { + Ok(entry) => return Ok(entry.value().map(|v| v.to_string())), + Err(_) => continue, + } + } + } + Ok(None) +} + pub fn save_git_config_item(git_repo: &Option<&Repo>, item: &str, value: &str) -> Result<()> { if let Some(git_repo) = git_repo { git_repo.save_git_config_item(item, value, false) -- cgit v1.2.3