Repository navigation
Apply recent "pub get" workspace improves to "pub upgrade" - #6000
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6000 +/- ##
==========================================
+ Coverage 67.82% 67.91% +0.08%
==========================================
Files 170 170
Lines 13008 12994 -14
Branches 2580 2574 -6
==========================================
+ Hits 8823 8825 +2
+ Misses 3725 3707 -18
- Partials 460 462 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request refactors the pub get and pub upgrade commands to share common logic, significantly reducing code duplication. A new generic runPackageCommand method has been introduced to handle workspace detection, progress reporting, and batching for both commands. This correctly applies the recent workspace-aware improvements from pub get to pub upgrade, fixing the issue where pub upgrade would not run on the workspace root. The tests have also been refactored to be more concise and now cover both commands, ensuring the new shared logic works as expected for various scenarios.
There was a problem hiding this comment.
Pull request overview
This PR aligns the "pub upgrade" command behavior with the recent "pub get" workspace handling improvements, ensuring upgrades operate on Pub workspace roots (when applicable) rather than individual workspace projects. This addresses #5997.
Changes:
- Refactors package command execution into shared helpers so both
pub getandpub upgradeshare the same workspace/target resolution logic. - Exposes
upgradePackagesForUrivia the internal test API and adds tests validating invocation paths for both get/upgrade commands. - Increases
tryDelete()delete retry count to reduce flaky Windows test cleanup failures.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/extension/commands/packages.ts | Extracts shared command runner logic and applies workspace mapping to pub upgrade (matching pub get). |
| src/shared/vscode/interfaces.ts | Extends the internal test API surface with upgradePackagesForUri. |
| src/test/dart/pub/packages.test.ts | Refactors tests to cover both dart.getPackages and dart.upgradePackages invocation path behavior. |
| src/test/helpers.ts | Improves Windows reliability by increasing fs.rmSync retry count. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #5997