Repository navigation
feat(scan): read a GitHub repository with --github or its URL - #33
Conversation
|
Added the opt-in network test from the design ( |
|
Cross-review (rule 22), correctness and acceptance only, at 688b2fc. Agree / disagree / not reproduced per point. 1. Remote output equals a local scan through the same rules: agree, one disagreement below.
2. Read-only: agree, with the limits of what the tests can see.
3. No token without --auth: agree, reproduced independently. Stand-in server on two loopback ports logging the Authorization header of every request, real CLI in a subprocess (
4. Large repositories, truncation, rate limits: agree except the bug in 1.
Not reproduced: the full 237-test run and the by-hand runs against github.com (I ran only the stand-in probe above). |
…hort With a truncated recursive listing, --path . next to another path walked the root as if it were a folder and dropped the root files with exit 0. Found in the review of #33. Also tests --max-file-size on its own, since the comparison with a local scan does not cover it.
|
Review answered (thanks, phase-gpu):
|
) * feat(scan): read a GitHub repository with --github or its URL * docs: note where remote scan differs from its design * test(scan): compare a GitHub scan of a tag with its checkout, opt-in * test(scan): read messages without the colors CI forces * fix(scan): refuse the root as a --path when GitHub cuts the listing short With a truncated recursive listing, --path . next to another path walked the root as if it were a folder and dropped the root files with exit 0. Found in the review of #33. Also tests --max-file-size on its own, since the comparison with a local scan does not cover it.
Tier: physics (src change)
cdg scan OWNER/REPO --github, a github.com URL,--ref,--path,--auth,--max-file-sizein the Python build. Remote scans make GET requests to api.github.com and raw.githubusercontent.com; local scans make none, as before.source/ref/commitattributes, the MarkdownSource:line and the JSONsourceobject appear only for remote scans.--allow-remote, README and site (one issue after implementation).Stacked on #30 (design). Implements it for the Python build.
How it runs (
src/codigest/core/remote.py): the ref is resolved to one commit SHA, the recursive tree listing is filtered with the local scanner's rules (each ancestor folder, then the file;ALWAYS_IGNOREplus the root.gitignore; named paths walked one by one and joined), secret files and files over--max-file-sizeare dropped before any download, the size question runs on the listed sizes, and only then the selected files are downloaded into a temporary folder. The unchanged local scan reads that folder with a fixed root (ProjectContext(root=...)), and the folder is removed afterwards. Without--authno token is sent even ifGH_TOKENis set; with it, files come from the blob API so the token goes only to the API host.Changes outside the new module:
scan.py(options, the pre-flight check and rendering split into_confirm_sizeand_renderso the remote path reuses them, a--githubhint when a missing local path looks likeOWNER/REPO),common.py(fixed root),scanner.py(is_ignored_relfor paths not on disk),prompts.py(optionalsource,ref,commitattributes).Tests (
tests/test_remote_scan.py, fake GitHub intests/fake_github.pyon two local ports; no network):--pathsets (folders, files, line ranges, an ignored named file, a withheld named file, overlapping paths, a non-ASCII path), including the withheld list;.codigest/and out-of-scope files are never requested; the repository'sprompts.tomland config are not applied;--auth; with--auththe token is on API requests only and never in the output; token refused over plain http to a non-loopback host; a redirect to a third host is refused;Retry-After/ 5xx retried twice / unreachable host / failed download with no partial output / moved repository / unknown ref / renamed default branch / truncated listing with and without--path/ symlink, submodule and../entries / the size question before any download / the hard ceiling with-y;Results (Windows 11, Python 3.15.0b4):
uv run --with pytest pytest -q: 237 passed in 136 s (before the last three fixes below); after them,test_remote_scan.pyplus the scan, format, preset and agent-use tests: 107 passed.uvx ruff@0.17.1 checkandformat --check(the CI versions): clean.conventions.py check: 0 findings.cdg scan NaNIsaac/codigest --github --path LICENSE --path src/codigest/core/tokenizer.py:1-5 -s, the URL form with/tree/main/src/codigest/core --format markdown, a private repository without--auth(404 message) and an unknown ref. The opt-in network test from the design is not written yet.Fixed while testing (before this PR, no issue): a
--pathnaming an ignored file was scanned as the whole folder; overlapping--pathvalues used only the first; the repository name from the API went into URLs unchecked.Differences from the design, recorded in the doc: one 30 s socket timeout instead of separate connect/read timeouts; a file named with a line range counts with its whole size in the size question; fixtures are written by the tests instead of committed under
tests/fixtures/github/.