feat(pm): add git protocol spec parsing (1/3)#2622
Conversation
Summary of ChangesHello @killagu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request establishes foundational components for Git dependency resolution within the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a solid first step towards git dependency resolution by adding parsing for git and GitHub package specifications. The new PackageSpec enum and its associated parser are well-designed. However, I've identified a potential issue in how malformed github: specifiers are handled, which could lead to incorrect package resolution. Additionally, there's a small discrepancy between the PR description and the implementation of the new ResolveError::Git variant. I've provided suggestions to address these points, along with a minor suggestion for more idiomatic code. With these adjustments, the changes will be even more robust.
There was a problem hiding this comment.
Pull request overview
This PR adds foundational types and parsing logic for git dependency resolution in the ruborist crate, as part 1 of a 3-part series to internalize git dependency resolution. It introduces structured spec parsing, git-related data types, and error variants without implementing the actual git clone/resolution logic yet.
Changes:
- Add
PackageSpecenum with parsing logic to distinguish between Registry, Git, and GitHub shorthand specs - Add
is_non_registry_spec()helper to identify specs that should skip registry preloading (local + git specs) - Add
ResolveError::Gitvariant for structured git resolution errors - Add
GitCloneResultdata type to represent git clone operation results - Add
is_http_tarball_spec()helper for URL routing
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/ruborist/src/model/spec.rs | New file implementing PackageSpec enum and parsing logic for registry, git, and GitHub shorthand specs |
| crates/ruborist/src/traits/git.rs | New file defining GitCloneResult struct for git clone operation metadata |
| crates/ruborist/src/resolver/registry.rs | Add ResolveError::Git variant for git resolution errors |
| crates/ruborist/src/resolver/preload.rs | Add is_non_registry_spec() and deprecate is_local_spec() to include git specs |
| crates/ruborist/src/model/mod.rs | Export new spec module |
| crates/ruborist/src/traits/mod.rs | Export new git module |
| crates/ruborist/src/lib.rs | Add public re-exports for spec and git modules |
53c271e to
41d9077
Compare
ac30c61 to
27629a5
Compare
Add typed PackageSpec enum to utoo-ruborist for parsing dependency specifications into Registry, Git, and GitHub variants. This is the foundation for git dependency resolution support. - PackageSpec::parse() as idiomatic associated method - is_http_tarball_spec() for routing HTTP tarball specs - Re-export via utoo_ruborist::spec module - 10 unit tests + 2 doc-tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… GitCloneResult Extend the git protocol spec parsing layer: - Add is_non_registry_spec() covering git+, git://, github: prefixes alongside existing local specs (file:, link:, workspace:, portal:) - Deprecate is_local_spec() with alias pointing to new function - Add ResolveError::Git variant with Display/Error impls - Add GitCloneResult struct in traits/git.rs (data type only) - Re-export GitCloneResult via utoo_ruborist::git module Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Local and HttpTarball variants to PackageSpec enum - Handle bare user/repo GitHub shorthand in PackageSpec::parse - Handle file:/link:/workspace:/portal: as Local in PackageSpec::parse - Handle HTTP tarball URLs as HttpTarball in PackageSpec::parse - Rewrite is_non_registry_spec to delegate to PackageSpec::parse, eliminating duplicated logic and ensuring consistency - Remove is_http_tarball_spec from public re-export (now internal) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduce a `Protocol` enum with `PROTOCOL_PREFIXES` const table and `parse_prefix()` method, centralizing all protocol detection that was previously done via scattered `starts_with()` string checks. Rename `LocalProtocol` to `Protocol` and expand it to cover Git, GitHub, and Http protocols. Update `PackageSpec::from_str` to use `Protocol`-based routing, and rename `is_http_tarball_spec` to `has_tarball_extension`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5bcf09b to
c632bf8
Compare
|
为啥不用 thiserror ? |
c632bf8 to
5240767
Compare
11dbfbf to
3be048c
Compare
…ry_spec Add `SpecStr` trait on `str` with `parse_spec()` (infallible) and `is_registry_spec()` methods. This replaces the free function `is_non_registry_spec` with the more idiomatic `spec.is_registry_spec()` pattern, and avoids the awkward `parse().is_ok_and()` on an Infallible Result. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3be048c to
e07462e
Compare
|
Addressed @xusd320's review comments:
|
Introduces a Claude Code subagent that enforces idiomatic Rust style and project conventions. The review checklist is distilled from real PR #2622 feedback (xusd320, elrrrrrrr) covering 7 dimensions and 10 anti-patterns: incomplete enums, name-behavior mismatch, match guard escape, internal deprecated, excessive traits, sloppy error messages, YAGNI abstraction, string gymnastics, overly broad re-exports, and test blind spots. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…2635) * feat: add code-guard subagent for Rust code quality review Introduces a Claude Code subagent that enforces idiomatic Rust style and project conventions. The review checklist is distilled from real PR #2622 feedback (xusd320, elrrrrrrr) covering 7 dimensions and 10 anti-patterns: incomplete enums, name-behavior mismatch, match guard escape, internal deprecated, excessive traits, sloppy error messages, YAGNI abstraction, string gymnastics, overly broad re-exports, and test blind spots. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address code-guard PR review feedback - Remove zero-width U+200B chars, use 4-backtick outer fence for nested code blocks in Output Format template - Fix Display/fmt::Display redundancy: clarify they are the same trait - Fix reviewer attribution: guard escape analysis was by elrrrrrrr, not xusd320 - Align error message guidance with Rust API Guidelines (lowercase by default, note project-specific override) - Make Tool Usage section tool-agnostic (renamed to Methodology), add note that rules are reusable across editors - Add severity calibration table with concrete criteria - Expand A7-A10 anti-patterns with full explanations, code examples, and real-world context - Narrow title from "Code Quality Sentinel" to "Rust Idiom & Style Review Agent" to accurately reflect scope - Shorten AGENTS.md Purpose column for readability Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: add YAML frontmatter and structured workflow to code-guard agent - Add required frontmatter: name, description, tools (Read-only: Read, Grep, Glob, Bash), model (sonnet), maxTurns (30) - Replace "Trigger Scenarios" with step-by-step "When Invoked" workflow - Remove redundant "Methodology" section (tools already declared in frontmatter) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: move subagents to agents/ with .claude/agents symlink - Move code-guard.md from .claude/agents/ to agents/ (alongside existing utoopack-performance-agent.md) - Symlink .claude/agents -> ../agents for Claude Code discovery - Add YAML frontmatter to utoopack-performance-agent.md (name, description, tools, model, maxTurns) - Update AGENTS.md subagent table to list both agents with canonical paths in agents/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: set Comprehensive Rust as the style authority for code-guard Reference Google Android team's Comprehensive Rust course as the primary style standard. All review judgments must align with its idioms and conventions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…dback Address review comments from PR #2622/#2623: Phase 1 (correctness): - Add Local/Http variants to PackageSpec, unify is_non_registry_spec via parse delegation - Convert process_dependency to exhaustive match on PackageSpec variants - Fix TOCTOU race in cache writes with atomic tmp-dir + rename - Replace serde_json::Value with typed PkgNameVersion and direct VersionManifest deserialization Phase 2 (code quality): - Add thiserror derive for ResolveError, preserve error chain in Git variant - Convert GIT_CLONE_CACHE static to CloneCache instance variable in BuildDepsConfig - Consolidate cfg(native-git) checks inside git.rs, remove stubs from builder.rs - Move std::env reads out of ruborist into PM's git_resolver.rs (auth_token parameter) - Small fixes: NonZeroU32::MIN, with_cache_dir(PathBuf), cache_path→store_path, submodule skip trace, error message quote consistency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Split from #2603 — Part 1 of 3 for git dependency resolution.
PackageSpecenum (Registry,Git,GitHub) withPackageSpec::parse()associated methodis_non_registry_spec()with#[deprecated]alias foris_local_specResolveError::Git { url, message }structured error variantGitCloneResultdata type intraits/git.rs(data only, no implementation)is_http_tarball_spec()for URL routingArchitectural decisions
PackageSpec::parse()as associated method (not free function) — Rust idiomaticRegistry/Git/GitHubvariants — no YAGNIHttp/FileDir/FileTarballtraits/git.rscontains only data types, not implementationsResolveError::Git { url, message }instead ofGit(String)Test plan
cargo check -p utoo-ruboristpassescargo test -p utoo-ruborist— 121 tests + 8 doctests passPackageSpec::parse()edge cases🤖 Generated with Claude Code