From ee85ed822a76fa4c0dac8f6d9978f5f530b86910 Mon Sep 17 00:00:00 2001 From: Zhengshou Lai Date: Thu, 30 Jul 2026 15:32:48 +0800 Subject: [PATCH] fix(git): prefer connections.proxy over legacy flat keys Keep git proxy lookup aligned with layered config, with proxy_* fallback. --- mytoolkit/commands/git.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mytoolkit/commands/git.py b/mytoolkit/commands/git.py index c735515..8a8bb6d 100644 --- a/mytoolkit/commands/git.py +++ b/mytoolkit/commands/git.py @@ -11,12 +11,22 @@ from mytoolkit.config import config def _get_proxies() -> dict[str, str]: - """Get git proxies from config.""" - proxies = {} + """Get git proxies from config. + + Prefers hierarchical ``connections.proxy.``; falls back to legacy + flat ``proxy_`` keys for older configs. + """ + proxies: dict[str, str] = {} + nested = config.get("connections.proxy") + if isinstance(nested, dict): + for name, value in nested.items(): + if isinstance(value, str) and value: + proxies[str(name)] = value + if proxies: + return proxies for key, value in config.get_all().items(): - if key.startswith("proxy_"): - name = key[6:] # Remove 'proxy_' prefix - proxies[name] = value + if key.startswith("proxy_") and isinstance(value, str) and value: + proxies[key[6:]] = value return proxies