Skip to content

Commit 09481aa

Browse files
committed
Version 2.12.0-29.10.beta
* Cherry-pick refs/changes/64/172064/1 to beta * Cherry-pick 0258778 to beta * Cherry-pick e205acb to beta
2 parents 6fee8e2 + fab6ef7 commit 09481aa

File tree

6 files changed

+34
-16
lines changed

6 files changed

+34
-16
lines changed

pkg/nnbd_migration/lib/migration_cli.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,9 @@ class MigrationCliRunner {
679679
if (!options.ignoreErrors) {
680680
throw MigrationExit(1);
681681
}
682+
} else if (analysisResult.allSourcesAlreadyMigrated) {
683+
_logAlreadyMigrated();
684+
throw MigrationExit(0);
682685
} else {
683686
logger.stdout('No analysis issues found.');
684687
}
@@ -725,6 +728,9 @@ View the migration suggestions by visiting:
725728
Use this interactive web view to review, improve, or apply the results.
726729
When finished with the preview, hit ctrl-c to terminate this process.
727730
731+
If you make edits outside of the web view (in your IDE), use the 'Rerun from
732+
sources' action.
733+
728734
''');
729735

730736
// Block until sigint (ctrl-c).
@@ -866,6 +872,10 @@ Exception details:
866872
}
867873
}
868874

875+
void _logAlreadyMigrated() {
876+
logger.stdout(migratedAlready);
877+
}
878+
869879
void _logErrors(AnalysisResult analysisResult) {
870880
logger.stdout('');
871881

@@ -930,6 +940,14 @@ get erroneous migration suggestions.
930940
_dartFixListener,
931941
_fixCodeProcessor._task.instrumentationListener,
932942
analysisResult);
943+
} else if (analysisResult.allSourcesAlreadyMigrated) {
944+
_logAlreadyMigrated();
945+
return MigrationState(
946+
_fixCodeProcessor._task.migration,
947+
_fixCodeProcessor._task.includedRoot,
948+
_dartFixListener,
949+
_fixCodeProcessor._task.instrumentationListener,
950+
analysisResult);
933951
} else {
934952
logger.stdout(ansi.emphasized('Re-generating migration suggestions...'));
935953
return await _fixCodeProcessor.runLaterPhases();

pkg/nnbd_migration/lib/src/exceptions.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import 'package:nnbd_migration/src/messages.dart';
44
/// A [StateError] specific to the ways that the NNBD experiment can be
55
/// misconfigured which may prevent the tool from working.
66
class ExperimentStatusException extends StateError {
7-
/// All files included in the migration dir have already been migrated.
8-
ExperimentStatusException.migratedAlready() : super(migratedAlready);
9-
107
/// The SDK was analyzed without NNBD semantics.
118
ExperimentStatusException.sdkExperimentDisabled() : super(nnbdExperimentOff);
129

pkg/nnbd_migration/lib/src/messages.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import 'package:nnbd_migration/migration_cli.dart';
66

77
const String migratedAlready =
8-
"Seem to be migrating code that's already migrated";
8+
'All sources appear to be already migrated. Nothing to do.';
99
const String nnbdExperimentOff =
1010
'Analyzer seems to need the nnbd experiment on in the SDK.';
1111
const String sdkNnbdOff = 'Analysis seems to have an SDK without NNBD enabled.';
@@ -34,7 +34,7 @@ are currently importing the following non-null-safe libraries:
3434
3535
Please upgrade the packages containing these libraries to null safe versions
3636
before continuing. To see what null safe package versions are available, run
37-
the following command: `dart pub outdated --mode=null-safety --prereleases`.
37+
the following command: `dart pub outdated --mode=null-safety`.
3838
3939
To skip this check and try to migrate anyway, re-run with the flag
4040
`$_skipImportCheckFlag`.

pkg/nnbd_migration/lib/src/nullability_migration_impl.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,6 @@ class NullabilityMigrationImpl implements NullabilityMigration {
197197
}
198198

199199
void finish() {
200-
if (!_propagated) {
201-
// [finalizeInput] sets this field to `true`, so if it's still false, that
202-
// means it was never called; this probably means that all the code fed
203-
// to the migration tool was already migrated.
204-
throw ExperimentStatusException.migratedAlready();
205-
}
206200
_postmortemFileWriter?.write();
207201
_instrumentation?.finished();
208202
}

pkg/nnbd_migration/test/migration_cli_test.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ mixin _MigrationCliTestMethods on _MigrationCliTestBase {
235235

236236
Future<String> assertErrorExit(
237237
MigrationCliRunner cliRunner, FutureOr<void> Function() callback,
238-
{@required bool withUsage, dynamic expectedExitCode = anything}) async {
238+
{@required bool withUsage, dynamic expectedExitCode}) async {
239+
expectedExitCode ??= isNot(0);
239240
try {
240241
await callback();
241242
fail('Migration succeeded; expected it to abort with an error');
242243
} on MigrationExit catch (migrationExit) {
243244
expect(migrationExit.exitCode, isNotNull);
244-
expect(migrationExit.exitCode, isNot(0));
245245
expect(migrationExit.exitCode, expectedExitCode);
246246
}
247247
expect(cliRunner.isPreviewServerRunning, isFalse);
@@ -305,15 +305,15 @@ mixin _MigrationCliTestMethods on _MigrationCliTestBase {
305305
Future<String> assertRunFailure(List<String> args,
306306
{MigrationCli cli,
307307
bool withUsage = false,
308-
dynamic expectedExitCode = anything}) async {
308+
dynamic expectedExitCode}) async {
309+
expectedExitCode ??= isNot(0);
309310
cli ??= _createCli();
310311
MigrationCliRunner cliRunner;
311312
try {
312313
cliRunner =
313314
cli.decodeCommandLineArgs(MigrationCli.createParser().parse(args));
314315
} on MigrationExit catch (e) {
315316
expect(e.exitCode, isNotNull);
316-
expect(e.exitCode, isNot(0));
317317
expect(e.exitCode, expectedExitCode);
318318
return assertStderr(withUsage: withUsage);
319319
}
@@ -804,6 +804,15 @@ int? f() => null
804804
expect(output, isNot(contains('package:bar/bar.dart')));
805805
}
806806

807+
test_lifecycle_migration_already_performed() async {
808+
var projectContents = simpleProject(migrated: true);
809+
var projectDir = createProjectDir(projectContents);
810+
await assertRunFailure([projectDir], expectedExitCode: 0);
811+
var output = logger.stdoutBuffer.toString();
812+
expect(output,
813+
contains('All sources appear to be already migrated. Nothing to do.'));
814+
}
815+
807816
test_lifecycle_no_preview() async {
808817
var projectContents = simpleProject();
809818
var projectDir = createProjectDir(projectContents);

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ MAJOR 2
2828
MINOR 12
2929
PATCH 0
3030
PRERELEASE 29
31-
PRERELEASE_PATCH 7
31+
PRERELEASE_PATCH 10

0 commit comments

Comments
 (0)