Populate Dependency.Source for git and named-registry Cargo deps - #91
Merged
andrew merged 1 commit intoSep 5, 2026
Merged
Conversation
collectCargoDependencies left Source zero for every entry, so a
git or private-registry dependency was indistinguishable from a
plain crates.io one at version *. Set Source{Kind: SourceGit,
Value: url, Branch/Tag/Ref} when the table has a git key, and
Source{Kind: SourceRegistry, Value: name} for a named registry.
Plain, table-with-version, and workspace-inherited entries keep
the zero Source; path entries stay filtered.
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, matches the stated behavior, and is covered by a new unit test validating the key source-resolution cases.
Pull request overview
This PR makes Cargo dependency parsing preserve explicit source overrides by populating core.Dependency.Source for git = "...“ and named registry = "...“ dependency table entries. This improves downstream consumers’ ability to distinguish “unversioned crates.io” (Version="*", zero Source) from “unversioned but explicitly sourced” dependencies (e.g., Git).
Changes:
- Populate
Dependency.SourceincollectCargoDependenciesvia a newextractCargoSourcehelper. - Record Git URL plus optional
branch/tag/revselectors intocore.Sourcefields (Branch/Tag/Ref). - Add a focused unit test covering plain, table, git, named-registry, workspace-inherited, and path-filtered dependency cases.
File summaries
| File | Description |
|---|---|
| internal/cargo/cargo.go | Adds extractCargoSource and wires it into dependency collection so Cargo git/named-registry deps retain explicit source metadata. |
| internal/cargo/cargo_test.go | Adds a test ensuring Cargo TOML dependencies produce the expected Source values and that path deps remain filtered. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
collectCargoDependenciesleftDependency.Sourcezero for every entry, so agitor private-registrydependency was indistinguishable from a plain crates.io one at version*.extractCargoSourcesetsSource{Kind: SourceGit, Value: url}(withBranch/Tag/Reffrombranch/tag/rev) when the table has agitkey, andSource{Kind: SourceRegistry, Value: name}for a namedregistry. Plain,{version = ...}, and{workspace = true}entries keep the zeroSourcesince they resolve against the default registry;pathentries stay filtered as before.Stacked on #90 to avoid a mechanical conflict in
cargo_test.go.