Skip to content

Parse the Cargo package list by column instead of by regex - #5312

Merged
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
fix/5239-cargo-blank-package-id
Aug 21, 2026
Merged

Parse the Cargo package list by column instead of by regex#5312
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
fix/5239-cargo-blank-package-id

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

This pull request refactors and improves the way the Cargo package manager integration parses and processes the output of cargo install-update --list and cargo install --list. The changes introduce a more robust and testable parsing logic, replace brittle regular expressions with structured parsing, and add comprehensive unit tests to ensure correctness. Additionally, some minor improvements are made to package details handling.

Parsing and Data Model Improvements:

  • Introduced a new CargoListEntry record and moved parsing logic for installed and updatable Cargo packages to a new file, CargoListParsing.cs, with robust handling of edge cases and malformed input. This includes new regexes and parsing methods for both update and install list outputs.
  • Refactored the Cargo manager to use the new parsing logic and data model, replacing previous use of Match and regexes with CargoListEntry objects throughout the codebase. This improves maintainability and correctness, especially in edge cases.

Testing:

  • Added a comprehensive new test suite CargoListParsingTests.cs, covering various real-world and edge case outputs from Cargo, ensuring the new parsing logic is robust and reliable.

Minor Improvements:

  • Improved handling of package details in CargoPkgDetailsHelper.cs by using FirstOrDefault and null checks to avoid exceptions when version data is missing.

These changes make the Cargo integration more reliable, easier to maintain, and better tested.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors Cargo package-list parsing into structured, testable logic and safely handles missing package-version metadata.

Changes:

  • Adds column-based parsing for Cargo installed/update output.
  • Integrates parsed entries with Cargo package discovery and fallback behavior.
  • Adds comprehensive parser tests and null-safe package details handling.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
CargoListParsingTests.cs Tests normal, malformed, prerelease, Git, and fallback output formats.
CargoPkgDetailsHelper.cs Avoids exceptions when matching version metadata is absent.
CargoListParsing.cs Defines the parsed entry model and parsing routines.
Cargo.cs Uses structured entries for installed packages and updates.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit b0d8bcb into main Aug 21, 2026
6 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the fix/5239-cargo-blank-package-id branch August 21, 2026 20:06
@GabrielDuf Gabriel Dufresne (GabrielDuf) linked an issue Aug 21, 2026 that may be closed by this pull request
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Cargo package not identified (blank name and ID)

3 participants