Skip to content

Commit 3031af1

Browse files
flutteractionsbotsuryaKommana2662
authored andcommitted
Revert: [flutter_tools] forward --offline flag to pub.get in update-packages (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.
1 parent 5aaf66e commit 3031af1

2 files changed

Lines changed: 5 additions & 61 deletions

File tree

‎packages/flutter_tools/lib/src/commands/update_packages.dart‎

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -243,36 +243,20 @@ class UpdatePackagesCommand extends FlutterCommand {
243243
_checkPins(rootDirectory);
244244

245245
// Pub get for the workspace.
246-
await _pubGet(
247-
rootProject,
248-
enforceLockfile: !forceUpgrade && cherryPicks.isEmpty && !updateHashes,
249-
offline: offline,
250-
);
246+
await _pubGet(rootProject, !forceUpgrade && cherryPicks.isEmpty && !updateHashes);
251247

252248
// Manually do a pub get for packages not part of the workspace.
253249
// See https://github.com/flutter/flutter/pull/170364.
254-
await _pubGet(toolProject, enforceLockfile: false, offline: offline);
255-
await _pubGet(
256-
FlutterProject.fromDirectory(hooksUserDefineIntegrationTestDirectory),
257-
enforceLockfile: false,
258-
offline: offline,
259-
);
250+
await _pubGet(toolProject, false);
251+
await _pubGet(FlutterProject.fromDirectory(hooksUserDefineIntegrationTestDirectory), false);
260252

261253
await _downloadCoverageData();
262254

263255
return FlutterCommandResult.success();
264256
}
265257

266-
Future<void> _pubGet(
267-
FlutterProject project, {
268-
required bool enforceLockfile,
269-
required bool offline,
270-
}) async => pub.get(
271-
context: PubContext.pubGet,
272-
project: project,
273-
enforceLockfile: enforceLockfile,
274-
offline: offline,
275-
);
258+
Future<void> _pubGet(FlutterProject project, bool enforceLockfile) async =>
259+
pub.get(context: PubContext.pubGet, project: project, enforceLockfile: enforceLockfile);
276260

277261
Future<List<_ProjectDeps>> _upgrade({
278262
required bool forceUpgrade,

‎packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart‎

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -294,37 +294,6 @@ void main() {
294294
pub.pubspecs[flutterSdk.absolute.path]!.first.dependencies,
295295
Pubspec.parse(kFlutterWorkspacePubspecYaml).dependencies,
296296
);
297-
expect(pub.recordedPubGets, hasLength(3));
298-
expect(pub.recordedPubGets.map((r) => r.offline), everyElement(isFalse));
299-
expect(pub.recordedPubGets[0].enforceLockfile, isTrue);
300-
expect(pub.recordedPubGets[1].enforceLockfile, isFalse);
301-
expect(pub.recordedPubGets[2].enforceLockfile, isFalse);
302-
},
303-
overrides: <Type, Generator>{
304-
Pub: () => pub,
305-
FileSystem: () => fileSystem,
306-
ProcessManager: () => processManager,
307-
Cache: () => Cache.test(processManager: processManager),
308-
},
309-
);
310-
311-
testUsingContext(
312-
'updates packages --offline passes offline flag to pub get',
313-
() async {
314-
final command = UpdatePackagesCommand(
315-
toolContext: DelegatingToolContext(),
316-
verboseHelp: false,
317-
);
318-
await createTestCommandRunner(command).run(<String>['update-packages', '--offline']);
319-
expect(
320-
pub.pubspecs[flutterSdk.absolute.path]!.first.dependencies,
321-
Pubspec.parse(kFlutterWorkspacePubspecYaml).dependencies,
322-
);
323-
expect(pub.recordedPubGets, hasLength(3));
324-
expect(pub.recordedPubGets.map((r) => r.offline), everyElement(isTrue));
325-
expect(pub.recordedPubGets[0].enforceLockfile, isTrue);
326-
expect(pub.recordedPubGets[1].enforceLockfile, isFalse);
327-
expect(pub.recordedPubGets[2].enforceLockfile, isFalse);
328297
},
329298
overrides: <Type, Generator>{
330299
Pub: () => pub,
@@ -668,9 +637,6 @@ class _FakePub extends Fake implements Pub {
668637
(pubspecs[project.directory.path] ??= <Pubspec>[]).add(pubspec);
669638
}
670639

671-
final recordedPubGets =
672-
<({PubContext context, FlutterProject project, bool enforceLockfile, bool offline})>[];
673-
674640
@override
675641
Future<void> get({
676642
required PubContext context,
@@ -683,12 +649,6 @@ class _FakePub extends Fake implements Pub {
683649
bool enforceLockfile = false,
684650
PubOutputMode outputMode = PubOutputMode.all,
685651
}) async {
686-
recordedPubGets.add((
687-
context: context,
688-
project: project,
689-
enforceLockfile: enforceLockfile,
690-
offline: offline,
691-
));
692652
(pubspecs[project.directory.path] ??= <Pubspec>[]).add(
693653
Pubspec.parse(project.pubspecFile.readAsStringSync()),
694654
);

0 commit comments

Comments
 (0)