Skip to content

Conversation

@GaryQian
Copy link
Contributor

@GaryQian GaryQian commented Mar 17, 2022

Adds

  • flutter migrate start
  • flutter migrate abandon
  • flutter migrate apply
  • flutter migrate status

This feature includes the following sections:

  • migrate_compute.dart - performs the majority of the migration computation via the computeMigration function.
  • migrate_utils.dart - Utility and data classes that provide utility methods to access git and other bash/dos commands.
  • migrate_manifest - Data class that wraps a MigrateResult and represents the manifest that is output alongside the staged files
  • custom_merge.dart - Handles manually merging files with known structures to produce better results. The initial version only manually merges .metadata though this should be expanded to include pubspec.yaml and other commonly encountered known files.

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 17, 2022
@GaryQian GaryQian changed the title Flutter migrate command [WIP] Flutter migrate command Mar 17, 2022
@skia-gold
Copy link

Gold has detected about 1 new digest(s) on patchset 5.
View them at https://flutter-gold.skia.org/cl/github/100284

This was referenced Mar 24, 2022
@GaryQian GaryQian changed the title [WIP] Flutter migrate command Flutter migrate command Mar 29, 2022
@GaryQian GaryQian requested a review from blasten March 30, 2022 02:39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just use systemTempDirectory.createTempSync as the rest of the tool does?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh sure, didn't know about this utility!

@christopherfujino
Copy link
Contributor

@GaryQian you have a validation error in your .ci.yaml that's causing none of the pre-submit checks to be scheduled: https://github.com/flutter/flutter/pull/100284/checks?check_run_id=5843295727

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you link to an issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest also checking in this block if it exists; if it doesn't, the likely reason is a typo in the argument.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be much more conservative and probably prompt for some user input unless --force was provided. Something like: `logger.printStatus('Are you sure you want to delete ${workingDirectory.absolute.path}?');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should handle this delete failing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you break up this line?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.printStatus('No git repo found. Please run in a project with an initialized git repo or initialize one with:');
logger.printError('No git repo found. Please run in a project with an initialized git repo or initialize one with:');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.printStatus('No migration in progress. Please run:');
logger.printError('No migration in progress. Please run:');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and throughout, if we're about to fail, we should log to STDERR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use printError, also we should log out where we checked, in case this was wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log to STDERR here why we're failing. Also, I think we should log something if they had uncommitted changes and we're overriding with --force

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is verbose, should we list the files we're modifying?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure you don't need to actually track these in your Commands. Any time you want verbose logging, you can call logger.printTrace(), and it will only actually show in the logger if the logger in the context is verbose. See https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/executable.dart#L126

@blasten
Copy link

blasten commented Apr 19, 2022

I was trying to run the example app in https://github.com/mobiten/flutter_staggered_animations/tree/master/example, and it just doesn't compile because it requires:

  1. Android embedding migration
  2. Bump Gradle, AGP, and Kotlin versions
  3. Set new compileSdkVersion, and ndkVersion.

I was curious about how the migration tool will work in this case.

@GaryQian
Copy link
Contributor Author

GaryQian commented Apr 20, 2022

We can't do the all of the v2 embedding migration for them, they will still have to migrate manually. The tool will do some of the more mundane v2 embedding migrations though such as add metadata.

Some of the things in (2) and (3) are handled as merge conflicts that will have to be manually resolved until we add smarter per-file custom merging, which the design allows to be modularly added in the future. If the files are not user modified though, we usually see clean bumps in versions.

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@GaryQian
Copy link
Contributor Author

Closing this as it has been superseded by #102598 and the individual PRs for each subcommand.

@GaryQian GaryQian closed this May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants