From 1077621beab64f5074ea88b56480de23a8153e1e Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 25 Jun 2026 07:07:44 +0000 Subject: [PATCH] refactor: rename GIT_GATE_DAEMON_TIMEOUT_SECS to GIT_GATE_TIMEOUT_SECS The constant now covers the daemon path, the HTTP backend access-hook, and the git http-backend CGI subprocess, so 'daemon' in the name was too narrow. Updated the comment to list all three current uses. --- bot_bottle/git_gate.py | 12 ++++++------ bot_bottle/git_http_backend.py | 6 +++--- tests/unit/test_git_http_backend.py | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bot_bottle/git_gate.py b/bot_bottle/git_gate.py index 239499c..acbf4d4 100644 --- a/bot_bottle/git_gate.py +++ b/bot_bottle/git_gate.py @@ -43,10 +43,10 @@ from .manifest import ManifestBottle, ManifestGitEntry # Short network alias for git-gate inside the sidecar bundle. The # agent's `.gitconfig` insteadOf rewrites resolve through this name. GIT_GATE_HOSTNAME = "git-gate" -# Bound half-open git client sessions. If an agent/tool runner is -# interrupted during push, git daemon should reap the receive-pack -# child instead of keeping the gate wedged indefinitely. -GIT_GATE_DAEMON_TIMEOUT_SECS = 15 +# Shared timeout (seconds) for all git-gate subprocess and CGI calls: +# git daemon (--timeout/--init-timeout), the access-hook subprocess in +# git_http_backend, and the git http-backend CGI subprocess. +GIT_GATE_TIMEOUT_SECS = 15 @dataclass(frozen=True) @@ -217,8 +217,8 @@ def git_gate_render_entrypoint(upstreams: tuple[GitGateUpstream, ...]) -> str: "", "exec git daemon \\", " --reuseaddr \\", - f" --timeout={GIT_GATE_DAEMON_TIMEOUT_SECS} \\", - f" --init-timeout={GIT_GATE_DAEMON_TIMEOUT_SECS} \\", + f" --timeout={GIT_GATE_TIMEOUT_SECS} \\", + f" --init-timeout={GIT_GATE_TIMEOUT_SECS} \\", " --base-path=/git \\", " --export-all \\", " --enable=receive-pack \\", diff --git a/bot_bottle/git_http_backend.py b/bot_bottle/git_http_backend.py index b39bd0d..4d63fef 100644 --- a/bot_bottle/git_http_backend.py +++ b/bot_bottle/git_http_backend.py @@ -16,7 +16,7 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from pathlib import Path from urllib.parse import urlsplit -from .git_gate import GIT_GATE_DAEMON_TIMEOUT_SECS +from .git_gate import GIT_GATE_TIMEOUT_SECS DEFAULT_PORT = 9420 @@ -49,7 +49,7 @@ class GitHttpHandler(BaseHTTPRequestHandler): [hook_path, "upload-pack", str(repo_dir), peer, peer], capture_output=True, check=False, - timeout=GIT_GATE_DAEMON_TIMEOUT_SECS, + timeout=GIT_GATE_TIMEOUT_SECS, ) if hook.returncode != 0: detail = (hook.stderr or hook.stdout).decode( @@ -113,7 +113,7 @@ class GitHttpHandler(BaseHTTPRequestHandler): env=env, capture_output=True, check=False, - timeout=GIT_GATE_DAEMON_TIMEOUT_SECS, + timeout=GIT_GATE_TIMEOUT_SECS, ) self._write_cgi_response(proc.stdout) diff --git a/tests/unit/test_git_http_backend.py b/tests/unit/test_git_http_backend.py index 314b952..af42373 100644 --- a/tests/unit/test_git_http_backend.py +++ b/tests/unit/test_git_http_backend.py @@ -9,7 +9,7 @@ import urllib.request from pathlib import Path from unittest import mock -from bot_bottle.git_gate import GIT_GATE_DAEMON_TIMEOUT_SECS +from bot_bottle.git_gate import GIT_GATE_TIMEOUT_SECS from bot_bottle.git_http_backend import GitHttpHandler, MAX_BODY_BYTES @@ -201,7 +201,7 @@ class TestGitHttpBackend(unittest.TestCase): for call in run.call_args_list: self.assertEqual( - GIT_GATE_DAEMON_TIMEOUT_SECS, + GIT_GATE_TIMEOUT_SECS, call.kwargs.get("timeout"), f"subprocess.run call missing timeout: {call}", )