@@ -21,6 +21,7 @@ import '../base/process.dart';
21
21
import '../cache.dart' ;
22
22
import '../convert.dart' ;
23
23
import '../dart/package_map.dart' ;
24
+ import '../git.dart' ;
24
25
import '../project.dart' ;
25
26
import '../version.dart' ;
26
27
@@ -208,7 +209,9 @@ class _DefaultPub implements Pub {
208
209
_botDetector = botDetector,
209
210
_processUtils = ProcessUtils (logger: logger, processManager: processManager),
210
211
_processManager = processManager,
211
- _stdio = null ;
212
+ _stdio = null {
213
+ _git = Git (currentPlatform: platform, runProcessWith: _processUtils);
214
+ }
212
215
213
216
@visibleForTesting
214
217
_DefaultPub .test ({
@@ -224,7 +227,9 @@ class _DefaultPub implements Pub {
224
227
_botDetector = botDetector,
225
228
_processUtils = ProcessUtils (logger: logger, processManager: processManager),
226
229
_processManager = processManager,
227
- _stdio = stdio;
230
+ _stdio = stdio {
231
+ _git = Git (currentPlatform: platform, runProcessWith: _processUtils);
232
+ }
228
233
229
234
final FileSystem _fileSystem;
230
235
final Logger _logger;
@@ -233,6 +238,7 @@ class _DefaultPub implements Pub {
233
238
final BotDetector _botDetector;
234
239
final ProcessManager _processManager;
235
240
final Stdio ? _stdio;
241
+ late final Git _git;
236
242
237
243
@override
238
244
Future <void > get ({
@@ -285,8 +291,10 @@ class _DefaultPub implements Pub {
285
291
if (packageConfigFile.existsSync ()) {
286
292
final Directory workspaceRoot = packageConfigFile.parent.parent;
287
293
final File lastVersion = workspaceRoot.childDirectory ('.dart_tool' ).childFile ('version' );
288
- final File currentVersion = _fileSystem.file (
289
- _fileSystem.path.join (Cache .flutterRoot! , 'version' ),
294
+ final versionFromFile = FlutterVersion (
295
+ flutterRoot: Cache .flutterRoot! ,
296
+ fs: _fileSystem,
297
+ git: _git,
290
298
);
291
299
final File pubspecYaml = project.pubspecFile;
292
300
final File pubLockFile = workspaceRoot.childFile ('pubspec.lock' );
@@ -319,7 +327,7 @@ class _DefaultPub implements Pub {
319
327
pubspecYaml.lastModifiedSync ().isBefore (pubLockFile.lastModifiedSync ()) &&
320
328
pubspecYaml.lastModifiedSync ().isBefore (packageConfigFile.lastModifiedSync ()) &&
321
329
lastVersion.existsSync () &&
322
- lastVersion.readAsStringSync () == currentVersion. readAsStringSync () ) {
330
+ lastVersion.readAsStringSync () == versionFromFile.frameworkVersion ) {
323
331
_logger.printTrace ('Skipping pub get: version match.' );
324
332
return ;
325
333
}
@@ -675,10 +683,12 @@ class _DefaultPub implements Pub {
675
683
final File lastVersion = _fileSystem.file (
676
684
_fileSystem.path.join (packageConfig.parent.path, 'version' ),
677
685
);
678
- final File currentVersion = _fileSystem.file (
679
- _fileSystem.path.join (Cache .flutterRoot! , 'version' ),
686
+ final versionFromFile = FlutterVersion (
687
+ flutterRoot: Cache .flutterRoot! ,
688
+ fs: _fileSystem,
689
+ git: _git,
680
690
);
681
- lastVersion.writeAsStringSync (currentVersion. readAsStringSync () );
691
+ lastVersion.writeAsStringSync (versionFromFile.frameworkVersion );
682
692
683
693
if (project.hasExampleApp && project.example.pubspecFile.existsSync ()) {
684
694
final File ? examplePackageConfig = findPackageConfigFile (project.example.directory);
0 commit comments