Skip to content

Populate Dependency.Source for git and named-registry Cargo deps - #91

Merged
andrew merged 1 commit into
cargo-workspace-inheritable-fieldsfrom
cargo-dependency-source
Sep 5, 2026
Merged

Populate Dependency.Source for git and named-registry Cargo deps#91
andrew merged 1 commit into
cargo-workspace-inheritable-fieldsfrom
cargo-dependency-source

Conversation

@andrew

@andrew andrew commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

collectCargoDependencies left Dependency.Source zero for every entry, so a git or private-registry dependency was indistinguishable from a plain crates.io one at version *.

extractCargoSource sets Source{Kind: SourceGit, Value: url} (with Branch/Tag/Ref from branch/tag/rev) when the table has a git key, and Source{Kind: SourceRegistry, Value: name} for a named registry. Plain, {version = ...}, and {workspace = true} entries keep the zero Source since they resolve against the default registry; path entries stay filtered as before.

Stacked on #90 to avoid a mechanical conflict in cargo_test.go.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.Source in collectCargoDependencies via a new extractCargoSource helper.
  • Record Git URL plus optional branch / tag / rev selectors into core.Source fields (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.

@andrew
andrew merged commit a49fb29 into main Sep 5, 2026
4 checks passed
@andrew
andrew deleted the cargo-dependency-source branch September 5, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants