-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate status #102785
Migrate status #102785
Conversation
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 (don't just cc him here, he won't see it! He's on Discord!). 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. |
Directory workingDirectory = project.directory.childDirectory(kDefaultMigrateWorkingDirectoryName); | ||
final String? customWorkingDirectoryPath = stringArg('working-directory'); | ||
if (customWorkingDirectoryPath != null) { | ||
if (customWorkingDirectoryPath.startsWith(fileSystem.path.separator) || customWorkingDirectoryPath.startsWith('/')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this work on Windows?
'working-directory', | ||
help: 'Specifies the custom migration working directory used to stage and edit proposed changes. ' | ||
'This path can be absolute or relative to the flutter project root.', | ||
valueHelp: 'path', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it mention the default directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, ill add it in the help text!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk if this will be painful, but can we name this something else, maybe workspace-directory
? I think this will be confusing with the current working directory of the tool invocation. In reading the code, I thought this field was a way to override the project directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to migrate_staging_dir
and the parameter to staging-directory
help: 'Shows the diff output when enabled. Enabled by default.', | ||
); | ||
argParser.addFlag( | ||
'show-added-files', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the use case for this flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of these flags assist in spam-reduction to make it easier to find the diffs/info the user is actually looking for.
valueHelp: 'path', | ||
); | ||
argParser.addFlag( | ||
'diff', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the use case for disabling this flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diffs can often be quite spammy, programmatic uses especially may not wish to have such an extensive output.
); | ||
argParser.addOption( | ||
'project-directory', | ||
help: 'The root directory of the flutter project.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for simplicity, should it only assume the current directory is the project directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tool is also intended to be used programmatically, where this option helps immensely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like if this is not provided we default to the current working directory, can we document this?
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{}; | ||
|
||
/// Manually marks the lines in a diff that should be printed unformatted for visbility. | ||
final Set<int> _initialDiffLines = <int>{0, 1}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do these lines contain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines just include the file names being diffed for example:
diff --git a/Users/garyq/projects/vanillabase1226/android/app/src/main/res/values/styles.xml b/Users/garyq/projects/vanillabase1226/migrate_working_dir/android/app/src/main/res/values/styles.xml
index 1f83a33..8dbda4a 100644
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you flesh out the dartdoc with this example?
int lineNumber = -1; | ||
for (final String line in result.diff!.split('\n')) { | ||
lineNumber++; | ||
if (line.startsWith('---') || line.startsWith('+++') || line.startsWith('&&') || _initialDiffLines.contains(lineNumber)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if a line starts with ---
, +++
, &&
in the original file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first character of the line is reserved for the + and - character, so lines that start with those strings in the original files would appear as _---
_+++
and _&&
where underscore is a space. The initial space character would cause the startsWith check to fail.
required this.logger, | ||
// TODO(garyq): Add each parameters in as subcommands land. | ||
// TODO(garyq): Add each of these back in as they land. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add in what?
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{}; | ||
|
||
/// Manually marks the lines in a diff that should be printed unformatted for visbility. | ||
final Set<int> _initialDiffLines = <int>{0, 1}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you flesh out the dartdoc with this example?
'working-directory', | ||
help: 'Specifies the custom migration working directory used to stage and edit proposed changes. ' | ||
'This path can be absolute or relative to the flutter project root.', | ||
valueHelp: 'path', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk if this will be painful, but can we name this something else, maybe workspace-directory
? I think this will be confusing with the current working directory of the tool invocation. In reading the code, I thought this field was a way to override the project directory.
); | ||
argParser.addOption( | ||
'project-directory', | ||
help: 'The root directory of the flutter project.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like if this is not provided we default to the current working directory, can we document this?
import 'package:flutter_tools/src/base/file_system.dart'; | ||
import 'package:flutter_tools/src/base/logger.dart'; | ||
import 'package:flutter_tools/src/base/platform.dart'; | ||
// import 'package:flutter_tools/src/base/terminal.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// import 'package:flutter_tools/src/base/terminal.dart'; |
@@ -0,0 +1,202 @@ | |||
// Copyright 2014 The Flutter Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move this file to packages/flutter_tools/test/command.shard/permeable/migrate_status_test.dart
?
] | ||
); | ||
expect(logger.statusText, contains(''' | ||
Newly addded file at added.file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling?
deleted_files: | ||
'''); | ||
|
||
expect(appDir.childFile('lib/main.dart').existsSync(), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed? we explicitly created it on line 55, are we testing it didn't get deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, this is leftover from another test this was based on. I can remove.
conflictFile.createSync(recursive: true); | ||
conflictFile.writeAsStringSync(''' | ||
line1 | ||
<<<<<<< /conflcit/conflict.file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling?
expect(logger.statusText, contains(''' | ||
@@ -1,3 +1,7 @@ | ||
line1 | ||
+<<<<<<< /conflcit/conflict.file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling?
Ready for another round. Thanks! @christopherfujino |
Directory workingDirectory = project.directory.childDirectory(kDefaultMigrateWorkingDirectoryName); | ||
final String? customWorkingDirectoryPath = stringArg('working-directory'); | ||
if (customWorkingDirectoryPath != null) { | ||
if (customWorkingDirectoryPath.startsWith(fileSystem.path.separator) || customWorkingDirectoryPath.startsWith(RegExp(r'[A-Z]:\\'))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get a path context from the filesystem and use https://pub.dev/documentation/path/latest/path/isAbsolute.html instead of re-implementing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, already did it, just needed to sync it with the other PRs
flutter migrate status
subcommand.This command shows the diffs staged in the migrate working directory and the manifest of files to be changed.
Depends on #101937