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
4 changes: 4 additions & 0 deletions src/repo_review/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ def _remote_path_processor(package: str) -> Path | GHPath:
rich.print(f"[red][bold]Error[/bold] accessing {e.url}", file=sys.stderr)
rich.print(f"[red]{e}", file=sys.stderr)
raise SystemExit(1) from None
except urllib.error.URLError as e:
rich.print(f"[red][bold]Error[/bold] accessing {package}", file=sys.stderr)
rich.print(f"[red]{e.reason}", file=sys.stderr)
raise SystemExit(1) from None


def main(args: list[str] | None = None) -> None:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_remote_path.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import urllib.error
from pathlib import Path

import pytest
Expand Down Expand Up @@ -55,3 +56,18 @@ def spy(package: object) -> object:

assert seen == ["gh:org/repo@main:src/pkg"]
assert isinstance(seen[0], str)


def test_remote_path_offline(
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
) -> None:
def fake_open(url: str) -> str: # noqa: ARG001
msg = "Name or service not known"
raise urllib.error.URLError(msg)

monkeypatch.setattr(GHPath, "open_url", staticmethod(fake_open))
with pytest.raises(SystemExit) as excinfo:
_remote_path_processor("gh:org/repo")

assert excinfo.value.code == 1
assert "Name or service not known" in capsys.readouterr().err
Loading