feat(reference): reference fetch に zip fallback を追加(Phase 4-D / Refs #191)#196
Merged
Conversation
SPEC #191 (Phase 4 umbrella) のサブタスク D として、git バイナリ不在 環境向けの archive 経由 fallback を追加する。`run_clone` が git の 有無を判定し、利用可能なら従来の `git clone --depth 1 ...`、そう でなければ GitHub の archive zip を ureq でダウンロードして展開する。 主な変更: - Cargo.toml に zip = "2" を追加(default features で deflate 含む) - src/reference/fetcher.rs::run_clone: git があれば既存ルート、無け れば fetch_via_zip に切り替える分岐を追加 - 新規 archive_url_for_branch / fetch_via_zip / extract_zip_to / detect_top_level_prefix / strip_prefix を実装 - extract_zip_to は GitHub archive 形式 (UnityCsReference-<branch>/ プレフィックス) を strip して dest に直接展開し、`..` を含む entry は安全のため reject - 新規 RED テスト 3 件: - archive_url_uses_unity_cs_reference_org - extract_zip_to_strips_top_level_prefix_and_writes_files - extract_zip_to_rejects_entries_with_parent_segments スコープ外(umbrella #191 で継続管理): - ネットワーク経由の実 download テスト(CI flake になりやすいため ローカル archive 生成のみ) - GitHub API レート制限への対応(既存の GITHUB_TOKEN / GH_TOKEN 透過 注入のみ) - 解凍済みファイルへの権限ビット保持(Unix 限定の chmod は未対応) ローカル検証: - cargo fmt -- --check: clean - cargo clippy --all-targets -- -D warnings: clean - cargo test --bin unity-cli: 389 passed / 0 failed - cargo llvm-cov --all-targets: TOTAL line coverage 90.88% - unity-cli skills lint --severity error: 15 skills / 0 violations Refs #191 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
reference fetchに GitHub archive 経由の zip fallback を追加する。gitバイナリが PATH に無い CI runner / slim image でも UnityCsReference キャッシュを取得できる。Changes
Cargo.toml:zip = "2"を[dependencies]に追加(default features で deflate 含む、圧縮済み GitHub archive を解凍可能)。src/reference/fetcher.rs::run_clone:ensure_git_available()が OK なら従来のgit clone、Err ならfetch_via_zipに切り替える分岐を追加。archive_url_for_branch(branch):https://github.com/Unity-Technologies/UnityCsReference/archive/refs/heads/<branch>.zipを構築。fetch_via_zip(branch, dest): ureq でアーカイブを取得し、GITHUB_TOKEN/GH_TOKENを透過注入。extract_zip_to(archive_bytes, dest): GitHub archive の top-level prefix (UnityCsReference-<branch>/) を strip してdestに展開。..を含む entry は安全のため reject。detect_top_level_prefix/strip_prefix: helpers。archive_url_uses_unity_cs_reference_orgextract_zip_to_strips_top_level_prefix_and_writes_files(ZipWriter で生成した buffer を使う)extract_zip_to_rejects_entries_with_parent_segmentsTesting
cargo fmt -- --check— cleancargo clippy --all-targets -- -D warnings— cleancargo test --bin unity-cli— 389 passed / 0 failedcargo llvm-cov --all-targets --summary-only -- --test-threads=1— TOTAL line coverage 90.88%unity-cli skills lint --severity error— 15 skills / 0 violationsClosing Issues
Related Issues / Links
Checklist
cargo clippy,cargo fmt,unity-cli skills lint)run_cloneの public API は不変)feat)Context
Phase 1 (SPEC #185) で
reference fetchはgit clone --depth 1前提で実装し、Phase 1.5 としてzipfallback を保留していた。本 PR はその保留分を land する。gitバイナリ不在の CI runner や slim Docker image でもunity-cli reference fetchが動くようになる。Out of Scope
umbrella SPEC #191 で継続管理する範囲:
Notes
zip = "2"の default features は bzip2 / lzma / zstd / aes-crypto / deflate を含むため、target サイズが多少増える。size sensitive な配布向けに後追いで feature を絞る検討余地あり。fetch_via_zip内のureq::Agent::new_with_defaultsは既存src/core/managed_binaries.rsの HTTP 利用に揃えた。リトライは未実装で、ネットワーク失敗時はエラーをそのまま伝播する。