Unverified Commit 195dca02 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] Fix "FormatException: Invalid date format" during version freshness check (#134088)

Fixes https://github.com/flutter/flutter/issues/134067
parent 61a388a4
......@@ -279,6 +279,8 @@ abstract class FlutterVersion {
localFrameworkCommitDate = DateTime.parse(_gitCommitDate(workingDirectory: flutterRoot));
} on VersionCheckError {
return;
} on FormatException {
return;
}
final DateTime? latestFlutterCommitDate = await _getLatestAvailableFlutterDate();
......
......@@ -133,6 +133,50 @@ void main() {
Cache: () => cache,
});
testUsingContext('does not crash when git log outputs malformed output', () async {
const String flutterUpstreamUrl = 'https://github.com/flutter/flutter.git';
final String malformedGitLogOutput = '${getChannelUpToDateVersion()}[0x7FF9E2A75000] ANOMALY: meaningless REX prefix used';
processManager.addCommands(<FakeCommand>[
const FakeCommand(
command: <String>['git', '-c', 'log.showSignature=false', 'log', '-n', '1', '--pretty=format:%H'],
stdout: '1234abcd',
),
const FakeCommand(
command: <String>['git', 'tag', '--points-at', '1234abcd'],
),
const FakeCommand(
command: <String>['git', 'describe', '--match', '*.*.*', '--long', '--tags', '1234abcd'],
stdout: '0.1.2-3-1234abcd',
),
FakeCommand(
command: const <String>['git', 'symbolic-ref', '--short', 'HEAD'],
stdout: channel,
),
FakeCommand(
command: const <String>['git', 'rev-parse', '--abbrev-ref', '--symbolic', '@{upstream}'],
stdout: 'origin/$channel',
),
const FakeCommand(
command: <String>['git', 'ls-remote', '--get-url', 'origin'],
stdout: flutterUpstreamUrl,
),
FakeCommand(
command: const <String>['git', '-c', 'log.showSignature=false', 'log', 'HEAD', '-n', '1', '--pretty=format:%ad', '--date=iso'],
stdout: malformedGitLogOutput,
),
]);
final FlutterVersion flutterVersion = FlutterVersion(clock: _testClock, fs: fs, flutterRoot: flutterRoot);
await flutterVersion.checkFlutterVersionFreshness();
expect(testLogger.statusText, isEmpty);
expect(processManager, hasNoRemainingExpectations);
}, overrides: <Type, Generator>{
ProcessManager: () => processManager,
Cache: () => cache,
});
testWithoutContext('prints nothing when Flutter installation looks out-of-date but is actually up-to-date', () async {
final FakeFlutterVersion flutterVersion = FakeFlutterVersion(branch: channel);
final BufferLogger logger = BufferLogger.test();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment