diff --git a/packages/shorebird_cli/lib/src/shorebird_env.dart b/packages/shorebird_cli/lib/src/shorebird_env.dart index 6a03e766..4a85d0dc 100644 --- a/packages/shorebird_cli/lib/src/shorebird_env.dart +++ b/packages/shorebird_cli/lib/src/shorebird_env.dart @@ -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 ?? diff --git a/packages/shorebird_cli/lib/src/shorebird_flutter.dart b/packages/shorebird_cli/lib/src/shorebird_flutter.dart index b5d48ac0..1f395154 100644 --- a/packages/shorebird_cli/lib/src/shorebird_flutter.dart +++ b/packages/shorebird_cli/lib/src/shorebird_flutter.dart @@ -286,24 +286,4 @@ class ShorebirdFlutter { result, ).map((e) => e.replaceFirst('origin/flutter_release/', '')).toList(); } - - /// Use the provided [version] of Flutter. - Future 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 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(); - } } diff --git a/packages/shorebird_cli/test/src/shorebird_env_test.dart b/packages/shorebird_cli/test/src/shorebird_env_test.dart index b21a6737..3e53d665 100644 --- a/packages/shorebird_cli/test/src/shorebird_env_test.dart +++ b/packages/shorebird_cli/test/src/shorebird_env_test.dart @@ -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', () { diff --git a/packages/shorebird_cli/test/src/shorebird_flutter_test.dart b/packages/shorebird_cli/test/src/shorebird_flutter_test.dart index 5f1a30cc..058583e8 100644 --- a/packages/shorebird_cli/test/src/shorebird_flutter_test.dart +++ b/packages/shorebird_cli/test/src/shorebird_flutter_test.dart @@ -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(