2415e751fe
PyJHora absence is now partial, tests write research manifests to tmp, the registry allows experimental_variant, and product links point at the Gitea repo. Early logs move to docs/history. Co-authored-by: Cursor <cursoragent@cursor.com>
69 lines
2.5 KiB
Python
69 lines
2.5 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
from scripts.remote_repo_visibility_check import (
|
|
build_report,
|
|
github_slug_from_remote_url,
|
|
parse_ls_remote,
|
|
)
|
|
|
|
|
|
def test_github_slug_from_remote_url_accepts_ssh_and_https() -> None:
|
|
assert github_slug_from_remote_url("git@github.com:732642856/yinduzhanxing.git") == "732642856/yinduzhanxing"
|
|
assert github_slug_from_remote_url("https://github.com/732642856/yinduzhanxing.git") == "732642856/yinduzhanxing"
|
|
|
|
|
|
def test_parse_ls_remote_separates_heads_and_tags() -> None:
|
|
parsed = parse_ls_remote(
|
|
"\n".join(
|
|
[
|
|
"abc123 refs/heads/main",
|
|
"def456 refs/heads/codex/release-hygiene-ci",
|
|
"aaa111 refs/tags/v1.0.0",
|
|
"bbb222 refs/tags/v1.0.0^{}",
|
|
]
|
|
)
|
|
)
|
|
assert parsed["heads"]["main"] == "abc123"
|
|
assert parsed["heads"]["codex/release-hygiene-ci"] == "def456"
|
|
assert parsed["tags"]["v1.0.0"] == "aaa111"
|
|
assert parsed["ref_count"] == 3
|
|
|
|
|
|
def test_gitea_remote_reports_provider_and_does_not_fall_back_to_legacy_slug(monkeypatch) -> None:
|
|
from scripts import remote_repo_visibility_check as mod
|
|
|
|
def fake_run_command(args: list[str], timeout: int) -> dict:
|
|
joined = " ".join(args)
|
|
if args[:3] == ["git", "rev-parse", "--abbrev-ref"]:
|
|
return {"ok": True, "returncode": 0, "stdout": "staging\n", "stderr": "", "error": ""}
|
|
if args[:2] == ["git", "rev-parse"]:
|
|
return {"ok": True, "returncode": 0, "stdout": "abc123\n", "stderr": "", "error": ""}
|
|
if args[:3] == ["git", "remote", "get-url"]:
|
|
return {
|
|
"ok": True,
|
|
"returncode": 0,
|
|
"stdout": "https://git.copse.top/root/Jyotisha.git\n",
|
|
"stderr": "",
|
|
"error": "",
|
|
}
|
|
if args[:2] == ["git", "ls-remote"]:
|
|
return {
|
|
"ok": True,
|
|
"returncode": 0,
|
|
"stdout": "abc123 refs/heads/main\ndef456 refs/heads/staging\n",
|
|
"stderr": "",
|
|
"error": "",
|
|
}
|
|
raise AssertionError(f"unexpected command: {joined}")
|
|
|
|
monkeypatch.setattr(mod, "run_command", fake_run_command)
|
|
report = build_report(8)
|
|
dumped = json.dumps(report)
|
|
assert report["provider"] == "gitea"
|
|
assert report["github_slug"] is None
|
|
assert report["status"] == "verified"
|
|
assert "732642856/yinduzhanxing" not in dumped
|
|
assert report["github_api"]["error"] == "not_github_remote"
|