@@ -80,7 +80,6 @@ abstract class Pub {
8080 @required Platform platform,
8181 @required BotDetector botDetector,
8282 @required Usage usage,
83- File Function () toolStampFile,
8483 }) = _DefaultPub ;
8584
8685 /// Runs `pub get` .
@@ -93,8 +92,6 @@ abstract class Pub {
9392 bool skipIfAbsent = false ,
9493 bool upgrade = false ,
9594 bool offline = false ,
96- bool checkLastModified = true ,
97- bool skipPubspecYamlCheck = false ,
9895 bool generateSyntheticPackage = false ,
9996 String flutterRootOverride,
10097 });
@@ -141,9 +138,7 @@ class _DefaultPub implements Pub {
141138 @required Platform platform,
142139 @required BotDetector botDetector,
143140 @required Usage usage,
144- File Function () toolStampFile,
145- }) : _toolStampFile = toolStampFile,
146- _fileSystem = fileSystem,
141+ }) : _fileSystem = fileSystem,
147142 _logger = logger,
148143 _platform = platform,
149144 _botDetector = botDetector,
@@ -159,7 +154,6 @@ class _DefaultPub implements Pub {
159154 final Platform _platform;
160155 final BotDetector _botDetector;
161156 final Usage _usage;
162- final File Function () _toolStampFile;
163157
164158 @override
165159 Future <void > get ({
@@ -168,88 +162,52 @@ class _DefaultPub implements Pub {
168162 bool skipIfAbsent = false ,
169163 bool upgrade = false ,
170164 bool offline = false ,
171- bool checkLastModified = true ,
172- bool skipPubspecYamlCheck = false ,
173165 bool generateSyntheticPackage = false ,
174166 String flutterRootOverride,
175167 }) async {
176168 directory ?? = _fileSystem.currentDirectory.path;
177-
178- final File pubSpecYaml = _fileSystem.file (
179- _fileSystem.path.join (directory, 'pubspec.yaml' ));
180169 final File packageConfigFile = _fileSystem.file (
181170 _fileSystem.path.join (directory, '.dart_tool' , 'package_config.json' ));
182171 final Directory generatedDirectory = _fileSystem.directory (
183172 _fileSystem.path.join (directory, '.dart_tool' , 'flutter_gen' ));
184173
185- if (! skipPubspecYamlCheck && ! pubSpecYaml.existsSync ()) {
186- if (! skipIfAbsent) {
187- throwToolExit ('$directory : no pubspec.yaml found' );
188- }
189- return ;
190- }
191-
192- final DateTime originalPubspecYamlModificationTime = pubSpecYaml.lastModifiedSync ();
193-
194- if (! checkLastModified || _shouldRunPubGet (
195- pubSpecYaml: pubSpecYaml,
196- packageConfigFile: packageConfigFile,
197- )) {
198- final String command = upgrade ? 'upgrade' : 'get' ;
199- final Status status = _logger.startProgress (
200- 'Running "flutter pub $command " in ${_fileSystem .path .basename (directory )}...' ,
201- timeout: const TimeoutConfiguration ().slowOperation,
174+ final String command = upgrade ? 'upgrade' : 'get' ;
175+ final Status status = _logger.startProgress (
176+ 'Running "flutter pub $command " in ${_fileSystem .path .basename (directory )}...' ,
177+ timeout: const TimeoutConfiguration ().slowOperation,
178+ );
179+ final bool verbose = _logger.isVerbose;
180+ final List <String > args = < String > [
181+ if (verbose)
182+ '--verbose'
183+ else
184+ '--verbosity=warning' ,
185+ ...< String > [
186+ command,
187+ '--no-precompile' ,
188+ ],
189+ if (offline)
190+ '--offline' ,
191+ ];
192+ try {
193+ await batch (
194+ args,
195+ context: context,
196+ directory: directory,
197+ failureMessage: 'pub $command failed' ,
198+ retry: true ,
199+ flutterRootOverride: flutterRootOverride,
202200 );
203- final bool verbose = _logger.isVerbose;
204- final List <String > args = < String > [
205- if (verbose)
206- '--verbose'
207- else
208- '--verbosity=warning' ,
209- ...< String > [
210- command,
211- '--no-precompile' ,
212- ],
213- if (offline)
214- '--offline' ,
215- ];
216- try {
217- await batch (
218- args,
219- context: context,
220- directory: directory,
221- failureMessage: 'pub $command failed' ,
222- retry: true ,
223- flutterRootOverride: flutterRootOverride,
224- );
225- status.stop ();
226- // The exception is rethrown, so don't catch only Exceptions.
227- } catch (exception) { // ignore: avoid_catches_without_on_clauses
228- status.cancel ();
229- rethrow ;
230- }
201+ status.stop ();
202+ // The exception is rethrown, so don't catch only Exceptions.
203+ } catch (exception) { // ignore: avoid_catches_without_on_clauses
204+ status.cancel ();
205+ rethrow ;
231206 }
232207
233208 if (! packageConfigFile.existsSync ()) {
234209 throwToolExit ('$directory : pub did not create .dart_tools/package_config.json file.' );
235210 }
236- if (pubSpecYaml.lastModifiedSync () != originalPubspecYamlModificationTime) {
237- throwToolExit (
238- '$directory : unexpected concurrent modification of '
239- 'pubspec.yaml while running pub.' );
240- }
241- // We don't check if dotPackages was actually modified, because as far as we can tell sometimes
242- // pub will decide it does not need to actually modify it.
243- final DateTime now = DateTime .now ();
244- if (now.isBefore (originalPubspecYamlModificationTime)) {
245- _logger.printError (
246- 'Warning: File "${_fileSystem .path .absolute (pubSpecYaml .path )}" was created in the future. '
247- 'Optimizations that rely on comparing time stamps will be unreliable. Check your '
248- 'system clock for accuracy.\n '
249- 'The timestamp was: $originalPubspecYamlModificationTime \n '
250- 'The time now is: $now '
251- );
252- }
253211 await _updatePackageConfig (
254212 packageConfigFile,
255213 generatedDirectory,
@@ -392,23 +350,6 @@ class _DefaultPub implements Pub {
392350 return < String > [sdkPath, ...arguments];
393351 }
394352
395- bool _shouldRunPubGet ({ @required File pubSpecYaml, @required File packageConfigFile }) {
396- if (! packageConfigFile.existsSync ()) {
397- return true ;
398- }
399- final DateTime dotPackagesLastModified = packageConfigFile.lastModifiedSync ();
400- if (pubSpecYaml.lastModifiedSync ().isAfter (dotPackagesLastModified)) {
401- return true ;
402- }
403- final File toolStampFile = _toolStampFile != null ? _toolStampFile () : null ;
404- if (toolStampFile != null &&
405- toolStampFile.existsSync () &&
406- toolStampFile.lastModifiedSync ().isAfter (dotPackagesLastModified)) {
407- return true ;
408- }
409- return false ;
410- }
411-
412353 // Returns the environment value that should be used when running pub.
413354 //
414355 // Includes any existing environment variable, if one exists.
0 commit comments