Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/git_commit_guard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ def check_signature(rev, result):
result.info("signature type: SSH", check=Check.SIGNATURE)
return
result.error("commit is not signed (GPG/SSH)", check=Check.SIGNATURE)
except subprocess.TimeoutExpired:
result.error(
"git operation timed out — cannot verify signature",
check=Check.SIGNATURE,
)
except (urllib.error.URLError, TimeoutError):
result.error(
"GitHub API unreachable — cannot verify signature",
Expand Down
10 changes: 10 additions & 0 deletions tests/test_git_commit_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,16 @@ def test_timeout_error_fails(self):
assert not r.ok
assert any("API unreachable" in msg for _, _, msg in r.errors)

def test_subprocess_timeout_fails_gracefully(self):
r = Result()
with patch(
"git_commit_guard._get_author_email",
side_effect=subprocess.TimeoutExpired(cmd="git", timeout=10),
):
check_signature("abc123", r)
assert not r.ok
assert any("git operation timed out" in msg for _, _, msg in r.errors)

def test_commits_api_resolves_username(self):
r = Result()
with (
Expand Down
Loading