refactor(shorebird_cli): remove legacy mutation APIs for flutterRevision (#2972)
This commit is contained in:
@@ -56,18 +56,6 @@ class ShorebirdEnv {
|
||||
).readAsStringSync().trim();
|
||||
}
|
||||
|
||||
/// Set the Shorebird Flutter revision.
|
||||
set flutterRevision(String revision) {
|
||||
if (revision == flutterRevision) return;
|
||||
File(
|
||||
p.join(shorebirdRoot.path, 'bin', 'internal', 'flutter.version'),
|
||||
).writeAsStringSync(revision);
|
||||
final snapshot = File(
|
||||
p.join(shorebirdRoot.path, 'bin', 'cache', 'shorebird.snapshot'),
|
||||
);
|
||||
if (snapshot.existsSync()) snapshot.deleteSync();
|
||||
}
|
||||
|
||||
/// Get the Shorebird Flutter revision.
|
||||
String get flutterRevision {
|
||||
return _flutterRevisionOverride ??
|
||||
|
||||
@@ -286,24 +286,4 @@ class ShorebirdFlutter {
|
||||
result,
|
||||
).map((e) => e.replaceFirst('origin/flutter_release/', '')).toList();
|
||||
}
|
||||
|
||||
/// Use the provided [version] of Flutter.
|
||||
Future<void> useVersion({required String version}) async {
|
||||
final revision = await git.revParse(
|
||||
revision: 'origin/flutter_release/$version',
|
||||
directory: _workingDirectory(),
|
||||
);
|
||||
|
||||
await useRevision(revision: revision);
|
||||
}
|
||||
|
||||
/// Use the provided [revision] of Flutter.
|
||||
Future<void> useRevision({required String revision}) async {
|
||||
await installRevision(revision: revision);
|
||||
|
||||
final version = await getVersionForRevision(flutterRevision: revision);
|
||||
final useFlutterProgress = logger.progress('Using Flutter $version');
|
||||
shorebirdEnv.flutterRevision = revision;
|
||||
useFlutterProgress.complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,78 +542,6 @@ test-revision
|
||||
equals(override),
|
||||
);
|
||||
});
|
||||
|
||||
test('can be set', () {
|
||||
const newRevision = 'new-revision';
|
||||
const revision = '''
|
||||
|
||||
test-revision
|
||||
|
||||
\r\n
|
||||
''';
|
||||
final version =
|
||||
File(
|
||||
p.join(
|
||||
shorebirdRoot.path,
|
||||
'bin',
|
||||
'internal',
|
||||
'flutter.version',
|
||||
),
|
||||
)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(revision, flush: true);
|
||||
final snapshot = File(
|
||||
p.join(shorebirdRoot.path, 'bin', 'cache', 'shorebird.snapshot'),
|
||||
)..createSync(recursive: true);
|
||||
|
||||
expect(
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision),
|
||||
'test-revision',
|
||||
);
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision = newRevision);
|
||||
expect(snapshot.existsSync(), isFalse);
|
||||
expect(version.readAsStringSync(), equals(newRevision));
|
||||
expect(
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision),
|
||||
newRevision,
|
||||
);
|
||||
});
|
||||
|
||||
test('setting to the same value does nothing', () {
|
||||
const newRevision = 'test-revision';
|
||||
const revision = '''
|
||||
|
||||
test-revision
|
||||
|
||||
\r\n
|
||||
''';
|
||||
final version =
|
||||
File(
|
||||
p.join(
|
||||
shorebirdRoot.path,
|
||||
'bin',
|
||||
'internal',
|
||||
'flutter.version',
|
||||
),
|
||||
)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(revision, flush: true);
|
||||
final snapshot = File(
|
||||
p.join(shorebirdRoot.path, 'bin', 'cache', 'shorebird.snapshot'),
|
||||
)..createSync(recursive: true);
|
||||
|
||||
expect(
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision),
|
||||
'test-revision',
|
||||
);
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision = newRevision);
|
||||
expect(snapshot.existsSync(), isTrue);
|
||||
expect(version.readAsStringSync(), equals(revision));
|
||||
expect(
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision),
|
||||
newRevision,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('shorebirdEngineRevision', () {
|
||||
|
||||
@@ -989,106 +989,6 @@ origin/flutter_release/3.10.6''';
|
||||
);
|
||||
});
|
||||
|
||||
group('useRevision', () {
|
||||
const revision = 'new-revision';
|
||||
|
||||
test('installs revision if it does not exist', () async {
|
||||
await expectLater(
|
||||
runWithOverrides(
|
||||
() => shorebirdFlutter.useRevision(revision: revision),
|
||||
),
|
||||
completes,
|
||||
);
|
||||
verify(
|
||||
() => git.clone(
|
||||
url: ShorebirdFlutter.flutterGitUrl,
|
||||
outputDirectory: p.join(flutterDirectory.parent.path, revision),
|
||||
args: ['--filter=tree:0', '--no-checkout'],
|
||||
),
|
||||
).called(1);
|
||||
verify(() => shorebirdEnv.flutterRevision = revision).called(1);
|
||||
});
|
||||
|
||||
test('skips installation if revision already exists', () async {
|
||||
Directory(
|
||||
p.join(flutterDirectory.parent.path, revision),
|
||||
).createSync(recursive: true);
|
||||
await expectLater(
|
||||
runWithOverrides(
|
||||
() => shorebirdFlutter.useRevision(revision: revision),
|
||||
),
|
||||
completes,
|
||||
);
|
||||
verifyNever(
|
||||
() => git.clone(
|
||||
url: ShorebirdFlutter.flutterGitUrl,
|
||||
outputDirectory: p.join(flutterDirectory.parent.path, revision),
|
||||
args: ['--filter=tree:0', '--no-checkout'],
|
||||
),
|
||||
);
|
||||
verify(() => shorebirdEnv.flutterRevision = revision).called(1);
|
||||
});
|
||||
});
|
||||
|
||||
group('useVersion', () {
|
||||
const version = '3.10.0';
|
||||
const newRevision = 'new-revision';
|
||||
|
||||
setUp(() {
|
||||
when(
|
||||
() => git.revParse(
|
||||
revision: any(named: 'revision'),
|
||||
directory: any(named: 'directory'),
|
||||
),
|
||||
).thenAnswer((_) async => newRevision);
|
||||
});
|
||||
|
||||
test('installs revision if it does not exist', () async {
|
||||
await expectLater(
|
||||
runWithOverrides(() => shorebirdFlutter.useVersion(version: version)),
|
||||
completes,
|
||||
);
|
||||
verify(
|
||||
() => git.revParse(
|
||||
revision: 'origin/flutter_release/$version',
|
||||
directory: p.join(flutterDirectory.parent.path, flutterRevision),
|
||||
),
|
||||
).called(1);
|
||||
verify(
|
||||
() => git.clone(
|
||||
url: ShorebirdFlutter.flutterGitUrl,
|
||||
outputDirectory: p.join(flutterDirectory.parent.path, newRevision),
|
||||
args: ['--filter=tree:0', '--no-checkout'],
|
||||
),
|
||||
).called(1);
|
||||
verify(() => shorebirdEnv.flutterRevision = newRevision).called(1);
|
||||
});
|
||||
|
||||
test('skips installation if revision already exists', () async {
|
||||
Directory(
|
||||
p.join(flutterDirectory.parent.path, newRevision),
|
||||
).createSync(recursive: true);
|
||||
await expectLater(
|
||||
runWithOverrides(() => shorebirdFlutter.useVersion(version: version)),
|
||||
completes,
|
||||
);
|
||||
verify(
|
||||
() => git.revParse(
|
||||
revision: 'origin/flutter_release/$version',
|
||||
directory: p.join(flutterDirectory.parent.path, flutterRevision),
|
||||
),
|
||||
).called(1);
|
||||
verifyNever(
|
||||
() => git.clone(
|
||||
url: ShorebirdFlutter.flutterGitUrl,
|
||||
outputDirectory: p.join(flutterDirectory.parent.path, newRevision),
|
||||
args: ['--filter=tree:0', '--no-checkout'],
|
||||
),
|
||||
);
|
||||
verify(() => shorebirdEnv.flutterRevision = newRevision).called(1);
|
||||
});
|
||||
});
|
||||
|
||||
group('formatVersion', () {
|
||||
test('returns the correct formatted value', () {
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user