summarylogtreecommitdiffstats
path: root/version.patch
blob: b893edac030deb063a2ca9cc6b9ec8268b238362 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
--- ./packages/flutter_tools/lib/src/version.dart.orig
+++ ./packages/flutter_tools/lib/src/version.dart
@@ -91,7 +91,7 @@
   }) {
     final File versionFile = getVersionFile(fs, flutterRoot);
 
-    if (!fetchTags && versionFile.existsSync()) {
+    if (versionFile.existsSync()) {
       final _FlutterVersionFromFile? version = _FlutterVersionFromFile.tryParseFromFile(
         versionFile,
         flutterRoot: flutterRoot,
@@ -102,19 +102,15 @@
     }

     // if we are fetching tags, ignore cached versionFile
-    if (fetchTags && versionFile.existsSync()) {
+    /* if (fetchTags && versionFile.existsSync()) {
       versionFile.deleteSync();
       final File legacyVersionFile = fs.file(fs.path.join(flutterRoot, 'version'));
       if (legacyVersionFile.existsSync()) {
         legacyVersionFile.deleteSync();
       }
-    }
+    } */

-    final String frameworkRevision = _runGit(
-      gitLog(<String>['-n', '1', '--pretty=format:%H']).join(' '),
-      globals.processUtils,
-      flutterRoot,
-    );
+    final String frameworkRevision = "archlinuxaur0000000000000000000000000000";
 
     return FlutterVersion.fromRevision(
       clock: clock,
@@ -145,7 +141,7 @@
       workingDirectory: flutterRoot,
       fetchTags: fetchTags,
     );
-    final String frameworkVersion = gitTagVersion.frameworkVersionFor(frameworkRevision);
+    final String frameworkVersion = globals.fs.file(globals.fs.path.join(flutterRoot, 'version')).readAsStringSync();
     return _FlutterVersionGit._(
       clock: clock,
       flutterRoot: flutterRoot,
@@ -217,11 +213,7 @@
   // TODO(fujino): calculate this relative to frameworkCommitDate for
   // _FlutterVersionFromFile so we don't need a git call.
   String get frameworkAge {
-    return _frameworkAge ??= _runGit(
-      FlutterVersion.gitLog(<String>['-n', '1', '--pretty=format:%ar']).join(' '),
-      globals.processUtils,
-      flutterRoot,
-    );
+    return _frameworkAge ??= 'unknown (arch linux aur package)';
   }
 
   void ensureVersionFile();
@@ -301,43 +293,7 @@
   /// Returns null if the cached version is out-of-date or missing, and we are
   /// unable to reach the server to get the latest version.
   Future<DateTime?> _getLatestAvailableFlutterDate() async {
-    globals.cache.checkLockAcquired();
-    final VersionCheckStamp versionCheckStamp = await VersionCheckStamp.load(globals.cache, globals.logger);
-
-    final DateTime now = _clock.now();
-    if (versionCheckStamp.lastTimeVersionWasChecked != null) {
-      final Duration timeSinceLastCheck = now.difference(
-        versionCheckStamp.lastTimeVersionWasChecked!,
-      );
-
-      // Don't ping the server too often. Return cached value if it's fresh.
-      if (timeSinceLastCheck < VersionFreshnessValidator.checkAgeConsideredUpToDate) {
-        return versionCheckStamp.lastKnownRemoteVersion;
-      }
-    }
-
-    // Cache is empty or it's been a while since the last server ping. Ping the server.
-    try {
-      final DateTime remoteFrameworkCommitDate = DateTime.parse(
-        await fetchRemoteFrameworkCommitDate(),
-      );
-      await versionCheckStamp.store(
-        newTimeVersionWasChecked: now,
-        newKnownRemoteVersion: remoteFrameworkCommitDate,
-      );
-      return remoteFrameworkCommitDate;
-    } on VersionCheckError catch (error) {
-      // This happens when any of the git commands fails, which can happen when
-      // there's no Internet connectivity. Remote version check is best effort
-      // only. We do not prevent the command from running when it fails.
-      globals.printTrace('Failed to check Flutter version in the remote repository: $error');
-      // Still update the timestamp to avoid us hitting the server on every single
-      // command if for some reason we cannot connect (eg. we may be offline).
-      await versionCheckStamp.store(
-        newTimeVersionWasChecked: now,
-      );
-      return null;
-    }
+    return null;
   }
 
   /// The date of the latest framework commit in the remote repository.
@@ -421,32 +377,13 @@
   bool lenient = false,
   required String? workingDirectory,
 }) {
-  final List<String> args = FlutterVersion.gitLog(<String>[
-    gitRef,
-    '-n',
-    '1',
-    '--pretty=format:%ad',
-    '--date=iso',
-  ]);
-  try {
-    // Don't plumb 'lenient' through directly so that we can print an error
-    // if something goes wrong.
-    return _runSync(
-      args,
-      lenient: false,
-      workingDirectory: workingDirectory,
-    );
-  } on VersionCheckError catch (e) {
-    if (lenient) {
-      final DateTime dummyDate = DateTime.fromMillisecondsSinceEpoch(0);
-      globals.printError('Failed to find the latest git commit date: $e\n'
-        'Returning $dummyDate instead.');
-      // Return something that DateTime.parse() can parse.
-      return dummyDate.toString();
-    } else {
-      rethrow;
-    }
-  }
+  final File versionFile = globals.fs.file(globals.fs.path.join(workingDirectory!, 'bin', 'cache', 'flutter.version.json'));
+
+  final _FlutterVersionFromFile version = _FlutterVersionFromFile.tryParseFromFile(
+    versionFile,
+    flutterRoot: workingDirectory,
+  )!;
+  return version.frameworkCommitDate;
 }
 
 class _FlutterVersionFromFile extends FlutterVersion {
@@ -472,11 +472,6 @@
 
   @override
   void ensureVersionFile() {
-    _ensureLegacyVersionFile(
-      fs: fs,
-      flutterRoot: flutterRoot,
-      frameworkVersion: frameworkVersion,
-    );
   }
 }
 
@@ -544,17 +539,6 @@
 
   @override
   void ensureVersionFile() {
-    _ensureLegacyVersionFile(
-      fs: fs,
-      flutterRoot: flutterRoot,
-      frameworkVersion: frameworkVersion,
-    );
-
-    const JsonEncoder encoder = JsonEncoder.withIndent('  ');
-    final File newVersionFile = FlutterVersion.getVersionFile(fs, flutterRoot);
-    if (!newVersionFile.existsSync()) {
-      newVersionFile.writeAsStringSync(encoder.convert(toJson()));
-    }
   }
 }
 
@@ -563,10 +547,6 @@
   required String flutterRoot,
   required String frameworkVersion,
 }) {
-  final File legacyVersionFile = fs.file(fs.path.join(flutterRoot, 'version'));
-  if (!legacyVersionFile.existsSync()) {
-    legacyVersionFile.writeAsStringSync(frameworkVersion);
-  }
 }
 
 /// Checks if the provided [version] is tracking a standard remote.
@@ -639,49 +566,7 @@
   ///
   /// Returns [VersionCheckError] if the tracking remote is not standard.
   VersionCheckError? run(){
-    final String? flutterGit = platform.environment['FLUTTER_GIT_URL'];
-    final String? repositoryUrl = version.repositoryUrl;
-
-    if (repositoryUrl == null) {
-      return VersionCheckError(
-        'The tool could not determine the remote upstream which is being '
-        'tracked by the SDK.'
-      );
-    }
-
-    // Strip `.git` suffix before comparing the remotes
-    final List<String> sanitizedStandardRemotes = <String>[
-      // If `FLUTTER_GIT_URL` is set, use that as standard remote.
-      if (flutterGit != null) flutterGit
-      // Else use the predefined standard remotes.
-      else ..._standardRemotes,
-    ].map((String remote) => stripDotGit(remote)).toList();
-
-    final String sanitizedRepositoryUrl = stripDotGit(repositoryUrl);
-
-    if (!sanitizedStandardRemotes.contains(sanitizedRepositoryUrl)) {
-      if (flutterGit != null) {
-        // If `FLUTTER_GIT_URL` is set, inform to either remove the
-        // `FLUTTER_GIT_URL` environment variable or set it to the current
-        // tracking remote.
-        return VersionCheckError(
-          'The Flutter SDK is tracking "$repositoryUrl" but "FLUTTER_GIT_URL" '
-          'is set to "$flutterGit".\n'
-          'Either remove "FLUTTER_GIT_URL" from the environment or set it to '
-          '"$repositoryUrl". '
-          'If this is intentional, it is recommended to use "git" directly to '
-          'manage the SDK.'
-        );
-      }
-      // If `FLUTTER_GIT_URL` is unset, inform to set the environment variable.
-      return VersionCheckError(
-        'The Flutter SDK is tracking a non-standard remote "$repositoryUrl".\n'
-        'Set the environment variable "FLUTTER_GIT_URL" to '
-        '"$repositoryUrl". '
-        'If this is intentional, it is recommended to use "git" directly to '
-        'manage the SDK.'
-      );
-    }
+    // the worse shit any code says about us, the worse for that code.
     return null;
   }
 
@@ -853,10 +738,7 @@
 }
 
 String _runGit(String command, ProcessUtils processUtils, String? workingDirectory) {
-  return processUtils.runSync(
-    command.split(' '),
-    workingDirectory: workingDirectory,
-  ).stdout.trim();
+  return '';
 }
 
 /// Runs [command] in the root of the Flutter installation and returns the
@@ -880,7 +762,7 @@
   if (revision == null) {
     return '';
   }
-  return revision.length > 10 ? revision.substring(0, 10) : revision;
+  return revision.length > 12 ? revision.substring(0, 12) : revision;
 }
 
 /// Version of Flutter SDK parsed from Git.
@@ -941,42 +823,10 @@
     bool fetchTags = false,
     String gitRef = 'HEAD'
   }) {
-    if (fetchTags) {
-      final String channel = _runGit('git symbolic-ref --short HEAD', processUtils, workingDirectory);
-      if (!kDevelopmentChannels.contains(channel) && kOfficialChannels.contains(channel)) {
-        globals.printTrace('Skipping request to fetchTags - on well known channel $channel.');
-      } else {
-        final String flutterGit = platform.environment['FLUTTER_GIT_URL'] ?? 'https://github.com/flutter/flutter.git';
-        _runGit('git fetch $flutterGit --tags -f', processUtils, workingDirectory);
-      }
-    }
-    // find all tags attached to the given [gitRef]
-    final List<String> tags = _runGit(
-      'git tag --points-at $gitRef', processUtils, workingDirectory).trim().split('\n');
-
-    // Check first for a stable tag
-    final RegExp stableTagPattern = RegExp(r'^\d+\.\d+\.\d+$');
-    for (final String tag in tags) {
-      if (stableTagPattern.hasMatch(tag.trim())) {
-        return parse(tag);
-      }
-    }
-    // Next check for a dev tag
-    final RegExp devTagPattern = RegExp(r'^\d+\.\d+\.\d+-\d+\.\d+\.pre$');
-    for (final String tag in tags) {
-      if (devTagPattern.hasMatch(tag.trim())) {
-        return parse(tag);
-      }
-    }
-
     // If we're not currently on a tag, use git describe to find the most
     // recent tag and number of commits past.
     return parse(
-      _runGit(
-        'git describe --match *.*.* --long --tags $gitRef',
-        processUtils,
-        workingDirectory,
-      )
+      globals.fs.file(globals.fs.path.join(Cache.flutterRoot!, 'version')).readAsStringSync()
     );
   }