Move Bundler settings parsing out of ruby_crawler into formats/gem/settings.rs, and read .bundle/config keys with one parser (two drifted today)

未關閉
#1,935 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
22/100
Issue 類型
重構
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
ruby, rust
領域
devtools

研究方向

Start with crates/socket-patch-core/src/crawlers/ruby_crawler.rs around bundle_config_setting_with and formats/gem/mirror.rs (config_key and the key loop), then compare how each reads .bundle/config lines. Step 1 is the parser move into formats/gem/settings.rs, which needs design choices about which key rules win. Done when formats/gem/* no longer imports crawlers::*, one key parser remains, and the ruby crawler, gem vendor, redirect and mirror tests pass.

由索引模型根據 Issue 內容生成。

描述

agent:triaged arch-audit priority:p1 refactor

[agent] Filed by the scheduled architecture audit (audit-core). Register: register.

Kind: refactor (placement plus a duplicated parser; extends E20/#833). Register ID: A57.

Problem

  • Bundler settings logic lives in the crawler. About 1,260 lines of it sit in crawlers/ruby_crawler.rs L1270-L2530:`` config scalar parsing and unquoting, the global and app config locations, the cache dir, the loaded manifest and lockfile, and the moved root.
  • Format modules import from that crawler. formats/gem/manifest.rs L58 and formats/gem/mirror.rs L16 import from crawlers::ruby_crawler, and so do vendor/gem.rs, vendor/lock_inventory/gem.rs, vex/discover/gem.rs, hosted/engine.rs, patch/redirect/upstream/gem.rs and the CLI.
  • The .bundle/config key line is parsed twice, and the copies drifted:
    • ruby_crawler::bundle_config_setting_with L2449-L2461 matches KEY: as a plain prefix: it accepts KEY:value with no space, does not decode quoted keys, and does not normalize legacy keys.
    • formats/gem/mirror.rs L125-L230 (config_key and the key loop) requires ": ", decodes Bundler 4.1's quoted keys, and normalizes dot/dash keys.
    • The drift is latent for BUNDLE_PATH/BUNDLE_GEMFILE/BUNDLE_LOCKFILE, because Bundler quotes only keys that contain :.
  • The Gemfile/gems.rb manifest name list is written twice: ruby_crawler.rs L276 and hosted/engine.rs L1167. formats/gem/mod.rs already holds BUNDLER_LOCKS.

Proposed change

This is a tracking issue; do the steps in order.

  1. Create formats/gem/settings.rs and move the pure parsers there: the config-map parse (one key-line reader, following mirror.rs's rules), unquote, bundler_truthy, and the tier rules from #1931. Also move a BUNDLER_MANIFEST_FILES const there.
  2. Leave only file and env I/O in the crawler, as a BundlerEnv::ambient() snapshot that replaces the 4 copies of the ambient-env tuple (L47, L169, L591, L670).
  3. Repoint the formats/gem, vendor, vex, hosted and redirect imports.

Size

About 10 files; mostly moves (~1,000 lines moved, ~−80 net).

Acceptance criteria

  • Behavior is unchanged: the ruby crawler, gem vendor, gem redirect and mirror tests pass.
  • formats/gem/* no longer imports crawlers::*.
  • One .bundle/config key parser remains.
主要語言
Rust
星號
9
分支
2
平均合併
18 小時 47 分鐘
30 天內合併 PR
637

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

SocketDev/socket-patch 的其他 Issue

查看 SocketDev/socket-patch 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。