Skip to content

Conversation

@GaryQian
Copy link
Contributor

@GaryQian GaryQian commented Dec 23, 2021

This PR adds a flutter migrate <action> command.

To use the migrate tool:

  • Run flutter migrate start --verbose
  • Fix conflicts found in the <project>/migrate_working_dir.
  • Run flutter migrate apply to apply the changes and clean up the working dir.

Subcommands:

  • flutter migrate start: Computes the migration and outputs changes into a working directory
  • flutter migrate apply: Checks the working directory conflicts are resolved and applies the changes to the project.
  • flutter migrate abandon: Deletes the current working directory and active migration.
  • flutter migrate status: Print the files that are slated to be changed as well as any conflicted files that need manual merging.

Notes on testing:

The migration tool requires full apps created with past flutter versions. This can be done two ways: a test fixture copy of pre-generated apps or cloning old versions of flutter and calling create on them after building the tool. The fixture method is much faster than the clone and create way.

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Dec 23, 2021
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

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

@GaryQian
Copy link
Contributor Author

GaryQian commented Feb 2, 2022

@blasten You are welcome to take a look/try it out. But heads up, the robustness still needs a lot of work. This works nicely for apps that were generated with a previous stable version as the fallback base commit discovery isn't quite fully fleshed out yet.

@GaryQian
Copy link
Contributor Author

GaryQian commented Feb 3, 2022

cc @jmagman @hellohuanlin This should be in a working-enough state to try out. Best way to see how it works cleanly is to create a new project with an old version of flutter, then run the migrate tool on it.

I'd be interested in if there are any ios specific issues/files/edge cases that should be handled.

@flutter-dashboard flutter-dashboard bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Feb 5, 2022
@GaryQian GaryQian changed the title [WIP] Flutter Migrate Flutter Migrate Feb 13, 2022
@GaryQian GaryQian added the c: new feature Nothing broken; request for a new capability label Feb 13, 2022
@GaryQian
Copy link
Contributor Author

GaryQian commented Feb 14, 2022

@jmagman I am seeing that the migration tool is finding merge conflicts when attempting to merge modern versions of ios/Runner.xcodeproj/project.pbxproj with old versions. This file seems to be a machine-handled file that is quite long and unwieldy. Fixing ~6 merge conflicts in this file does not seem like a good user experience.

Do you have any context on how this file changes over time, and the risk of breaking the file either due to a bad merge or it becoming outdated? Is it something we can choose to not handle and xcode will update it for us through context?

Here is an example conflicted file: https://gist.github.com/GaryQian/9313b4424b30ee0efe4e07464d2018c6

@jmagman
Copy link
Member

jmagman commented Feb 14, 2022

@jmagman I am seeing that the migration tool is finding merge conflicts when attempting to merge modern versions of ios/Runner.xcodeproj/project.pbxproj with old versions. This file seems to be a machine-handled file that is quite long and unwieldy. Fixing ~6 merge conflicts in this file does not seem like a good user experience.

Do you have any context on how this file changes over time, and the risk of breaking the file either due to a bad merge or it becoming outdated? Is it something we can choose to not handle and xcode will update it for us through context?

Here is an example conflicted file: https://gist.github.com/GaryQian/9313b4424b30ee0efe4e07464d2018c6

ios/Runner.xcodeproj/project.pbxproj is the Xcode project that defines how the app is compiled, scripts that call into Flutter, how plugins are embedded, user build settings like display name, signing details. The user could also add more complicated iOS features (extensions) like rich notification handling.
I wouldn't want users ever trying to handle merge conflicts in that file. We should either be confident we can change it for them:
https://github.com/flutter/flutter/blob/e028d0f046c20c61b7c7c8a23bc456f337410658/packages/flutter_tools/lib/src/ios/migrations/project_base_configuration_migration.dart
or the user should own that file and deal with changing it themselves.

@GaryQian
Copy link
Contributor Author

Ok, thanks for the explanation/advice. I think for now, we can just skip that file and have the user own it.

Currently, I definitely cannot guarantee we can fully handle the file, and manually resolving conflicts in it sounds very risky indeed. I will do some testing to see if not migrating that file can cause iOS build issues.

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

Once you're satisfied with this change I recommend breaking this up into smaller reviews to get thorough feedback.

@christopherfujino
Copy link
Contributor

Once you're satisfied with this change I recommend breaking this up into smaller reviews to get thorough feedback.

@GaryQian per this comment, it sounds like you're not really going to land this, but instead smaller incremental changes? Given this, I am going to mark this a draft so it doesn't show up in PR review. Feel free to mark ready for review if I am mistaken.

@christopherfujino christopherfujino marked this pull request as draft March 17, 2022 21:06
@GaryQian
Copy link
Contributor Author

Yeah, feel free to mark as draft. Ive already broken this up, and am using this as a master reference

@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

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

Superseded by #100284

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

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. c: new feature Nothing broken; request for a new capability tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants