Repository navigation
Revert: [flutter_tools] forward --offline flag to pub.get in update-packages - #193808
Conversation
…ackages (flutter#193619)" This reverts commit de6c00b.
There was a problem hiding this comment.
Code Review
This pull request simplifies the _pubGet helper method in UpdatePackagesCommand by removing the offline parameter and converting enforceLockfile into a positional boolean parameter. It also removes the corresponding offline-related tests and mock tracking. Feedback suggests reverting the change of enforceLockfile to a positional boolean parameter, recommending named arguments instead to maintain readability at call sites in accordance with Dart style guidelines.
| await _pubGet(rootProject, !forceUpgrade && cherryPicks.isEmpty && !updateHashes); | ||
|
|
||
| // Manually do a pub get for packages not part of the workspace. | ||
| // See https://github.com/flutter/flutter/pull/170364. | ||
| await _pubGet(toolProject, enforceLockfile: false, offline: offline); | ||
| await _pubGet( | ||
| FlutterProject.fromDirectory(hooksUserDefineIntegrationTestDirectory), | ||
| enforceLockfile: false, | ||
| offline: offline, | ||
| ); | ||
| await _pubGet(toolProject, false); | ||
| await _pubGet(FlutterProject.fromDirectory(hooksUserDefineIntegrationTestDirectory), false); | ||
|
|
||
| await _downloadCoverageData(); | ||
|
|
||
| return FlutterCommandResult.success(); | ||
| } | ||
|
|
||
| Future<void> _pubGet( | ||
| FlutterProject project, { | ||
| required bool enforceLockfile, | ||
| required bool offline, | ||
| }) async => pub.get( | ||
| context: PubContext.pubGet, | ||
| project: project, | ||
| enforceLockfile: enforceLockfile, | ||
| offline: offline, | ||
| ); | ||
| Future<void> _pubGet(FlutterProject project, bool enforceLockfile) async => | ||
| pub.get(context: PubContext.pubGet, project: project, enforceLockfile: enforceLockfile); |
There was a problem hiding this comment.
Using a positional boolean parameter (bool enforceLockfile) makes the call sites less readable and harder to understand at a glance (e.g., _pubGet(toolProject, false)). Following the Dart style guidelines, it is highly recommended to use named arguments for boolean parameters to improve code clarity and maintainability.
await _pubGet(
rootProject,
enforceLockfile: !forceUpgrade && cherryPicks.isEmpty && !updateHashes,
);
// Manually do a pub get for packages not part of the workspace.
// See https://github.com/flutter/flutter/pull/170364.
await _pubGet(toolProject, enforceLockfile: false);
await _pubGet(
FlutterProject.fromDirectory(hooksUserDefineIntegrationTestDirectory),
enforceLockfile: false,
);
await _downloadCoverageData();
return FlutterCommandResult.success();
}
Future<void> _pubGet(
FlutterProject project, {
required bool enforceLockfile,
}) async => pub.get(
context: PubContext.pubGet,
project: project,
enforceLockfile: enforceLockfile,
);References
- Effective Dart recommends using named arguments for boolean parameters to improve readability at call sites. (link)
|
Detected the If you add the The "Merge" button is also unlocked. To bypass presubmits as well as the tree status, press the GitHub "Add to Merge Queue". |
…ackages" (flutter#193838) Relands flutter#193619 (reverted in flutter#193808) with `const` added to `DelegatingToolContext()` in `update_packages_test.dart` to satisfy `prefer_const_constructors`. When running `flutter update-packages --offline`, the `--offline` flag was parsed and used to validate incompatible option combinations (such as `--force-upgrade` and `--cherry-pick-package`), but was not forwarded to the underlying `pub.get` invocations. Read `boolArg(_keyOffline)` in `_pubGet` and forward it to `pub.get` so that `pub` does not attempt network operations in offline environments. Fixes flutter#193423 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [breaking change policy]: https://flutter.dev/to/breaking-changes [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
…ackages (flutter#193808) Reverts: [[flutter_tools] forward --offline flag to pub.get in update-packages](flutter#193619) Initiated by: @cbracken Reason for reverting: info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart:315:24 • prefer_const_constructors Original PR Author: @bkonyi Reviewed By: @chingjun The original PR description is provided below: When running `flutter update-packages --offline`, the `--offline` flag was parsed and used to validate incompatible option combinations (such as `--force-upgrade` and `--cherry-pick-package`), but was not forwarded to the underlying `pub.get` invocations. Forward `offline` through `_pubGet` to `pub.get` so that `pub` does not attempt network operations in offline environments. Fixes flutter#193423 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
…ackages" (flutter#193838) Relands flutter#193619 (reverted in flutter#193808) with `const` added to `DelegatingToolContext()` in `update_packages_test.dart` to satisfy `prefer_const_constructors`. When running `flutter update-packages --offline`, the `--offline` flag was parsed and used to validate incompatible option combinations (such as `--force-upgrade` and `--cherry-pick-package`), but was not forwarded to the underlying `pub.get` invocations. Read `boolArg(_keyOffline)` in `_pubGet` and forward it to `pub.get` so that `pub` does not attempt network operations in offline environments. Fixes flutter#193423 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [breaking change policy]: https://flutter.dev/to/breaking-changes [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Reverts: [flutter_tools] forward --offline flag to pub.get in update-packages
Initiated by: @cbracken
Reason for reverting: info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart:315:24 • prefer_const_constructors
Original PR Author: @bkonyi
Reviewed By: @chingjun
The original PR description is provided below:
When running
flutter update-packages --offline, the--offlineflag was parsed and used to validate incompatible option combinations (such as--force-upgradeand--cherry-pick-package), but was not forwarded to the underlyingpub.getinvocations. Forwardofflinethrough_pubGettopub.getso thatpubdoes not attempt network operations in offline environments.Fixes #193423
Pre-launch Checklist
///).