This commit is contained in:
nightcityblade 2026-08-27 19:33:55 -05:00 committed by GitHub
commit aee3bf29aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 11 deletions

View file

@ -50,17 +50,7 @@ def fetch_open_issues(repo: str | None) -> list[dict]:
cmd = ["api", "--paginate", endpoint]
raw = gh(*cmd)
# gh --paginate concatenates JSON arrays, so we may get multiple arrays
issues = []
for line in raw.strip().splitlines():
line = line.strip()
if not line:
continue
parsed = json.loads(line)
if isinstance(parsed, list):
issues.extend(parsed)
else:
issues.append(parsed)
issues = json.loads(raw)
# Filter out pull requests (they also appear in the issues endpoint)
return [i for i in issues if "pull_request" not in i]

View file

@ -0,0 +1,27 @@
"""Unit tests for `.github/scripts/close_duplicate_issues.py`."""
import importlib.util
from pathlib import Path
import pytest
SCRIPT_PATH = Path(__file__).resolve().parents[2] / ".github" / "scripts" / "close_duplicate_issues.py"
@pytest.fixture(scope="module")
def duplicate_issues_module():
spec = importlib.util.spec_from_file_location("close_duplicate_issues", SCRIPT_PATH)
assert spec and spec.loader
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
def test_fetch_open_issues_preserves_unicode_line_separators(duplicate_issues_module, monkeypatch):
raw = '[{"number": 1, "body": "line\u2028separator"}, {"number": 2, "body": "paragraph\u2029separator"}]'
monkeypatch.setattr(duplicate_issues_module, "gh", lambda *args: raw)
assert duplicate_issues_module.fetch_open_issues("BerriAI/litellm") == [
{"number": 1, "body": "line\u2028separator"},
{"number": 2, "body": "paragraph\u2029separator"},
]