From db9857ce54e005d19b87d39f8b7f0d8caf371b0c Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 25 Jun 2026 07:03:18 +0000 Subject: [PATCH] refactor: import GIT_GATE_DAEMON_TIMEOUT_SECS instead of duplicating the value --- bot_bottle/git_http_backend.py | 12 ++++-------- tests/unit/test_git_http_backend.py | 9 +++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/bot_bottle/git_http_backend.py b/bot_bottle/git_http_backend.py index b553070..b39bd0d 100644 --- a/bot_bottle/git_http_backend.py +++ b/bot_bottle/git_http_backend.py @@ -16,18 +16,14 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from pathlib import Path from urllib.parse import urlsplit +from .git_gate import GIT_GATE_DAEMON_TIMEOUT_SECS + DEFAULT_PORT = 9420 # Bound memory use while still allowing ordinary git push packfiles. MAX_BODY_BYTES = 100 * 1024 * 1024 -# Timeout for the access-hook subprocess and git http-backend CGI subprocess. -# Mirrors GIT_GATE_DAEMON_TIMEOUT_SECS so both HTTP and daemon paths share the -# same bound: a hung upstream fetch in the access-hook or a stalled CGI child -# cannot wedge the sidecar indefinitely. -GIT_HTTP_BACKEND_TIMEOUT_SECS = 30 - class GitHttpHandler(BaseHTTPRequestHandler): server_version = "bot-bottle-git-http/1" @@ -53,7 +49,7 @@ class GitHttpHandler(BaseHTTPRequestHandler): [hook_path, "upload-pack", str(repo_dir), peer, peer], capture_output=True, check=False, - timeout=GIT_HTTP_BACKEND_TIMEOUT_SECS, + timeout=GIT_GATE_DAEMON_TIMEOUT_SECS, ) if hook.returncode != 0: detail = (hook.stderr or hook.stdout).decode( @@ -117,7 +113,7 @@ class GitHttpHandler(BaseHTTPRequestHandler): env=env, capture_output=True, check=False, - timeout=GIT_HTTP_BACKEND_TIMEOUT_SECS, + timeout=GIT_GATE_DAEMON_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 54094de..314b952 100644 --- a/tests/unit/test_git_http_backend.py +++ b/tests/unit/test_git_http_backend.py @@ -9,11 +9,8 @@ import urllib.request from pathlib import Path from unittest import mock -from bot_bottle.git_http_backend import ( - GIT_HTTP_BACKEND_TIMEOUT_SECS, - GitHttpHandler, - MAX_BODY_BYTES, -) +from bot_bottle.git_gate import GIT_GATE_DAEMON_TIMEOUT_SECS +from bot_bottle.git_http_backend import GitHttpHandler, MAX_BODY_BYTES class TestGitHttpBackend(unittest.TestCase): @@ -204,7 +201,7 @@ class TestGitHttpBackend(unittest.TestCase): for call in run.call_args_list: self.assertEqual( - GIT_HTTP_BACKEND_TIMEOUT_SECS, + GIT_GATE_DAEMON_TIMEOUT_SECS, call.kwargs.get("timeout"), f"subprocess.run call missing timeout: {call}", )