feat(git proxy): start 默认写 git http(s).proxy,stop 自动恢复,restart 继承状态(CI 用 --no-set-git)

This commit is contained in:
Zhengshou Lai
2026-08-19 21:17:02 +08:00
parent 9dddb8e0c3
commit fd37ea42fa
3 changed files with 62 additions and 18 deletions
+13 -1
View File
@@ -1,6 +1,6 @@
"""Unit tests for git proxy helpers."""
from mytoolkit.commands.git import _proxy_loopback_port
from mytoolkit.commands.git import _proxy_loopback_port, _restore_baseline
def test_proxy_loopback_port_http():
@@ -13,6 +13,18 @@ def test_proxy_loopback_port_rejects_remote():
assert _proxy_loopback_port("socks5://127.0.0.1:1080") is None
def test_restore_baseline_daemon_own_port_becomes_unset():
# Git already pointing at the daemon's loopback port → treat as no proxy.
assert _restore_baseline("http://127.0.0.1:38457", 38457) == "(not set)"
assert _restore_baseline("http://localhost:38457", 38457) == "(not set)"
def test_restore_baseline_foreign_values_pass_through():
assert _restore_baseline("http://127.0.0.1:10080", 38457) == "http://127.0.0.1:10080"
assert _restore_baseline("(not set)", 38457) == "(not set)"
assert _restore_baseline("http://127.0.0.1:38457", None) == "http://127.0.0.1:38457"
def test_procs_matching_filters_by_command():
from mytoolkit.commands.git import _procs_matching
import os