Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -32,33 +32,20 @@ Future<void> postProcess() async {
|
||||
}
|
||||
final String checkoutPath = Platform.environment['SDK_CHECKOUT_PATH']!;
|
||||
final String docsPath = path.join(checkoutPath, 'dev', 'docs');
|
||||
await runProcessWithValidations(
|
||||
<String>[
|
||||
'curl',
|
||||
'-L',
|
||||
'https://storage.googleapis.com/flutter_infra_release/flutter/$revision/api_docs.zip',
|
||||
'--output',
|
||||
zipDestination,
|
||||
'--fail',
|
||||
],
|
||||
docsPath,
|
||||
);
|
||||
await runProcessWithValidations(<String>[
|
||||
'curl',
|
||||
'-L',
|
||||
'https://storage.googleapis.com/flutter_infra_release/flutter/$revision/api_docs.zip',
|
||||
'--output',
|
||||
zipDestination,
|
||||
'--fail',
|
||||
], docsPath);
|
||||
|
||||
// Unzip to docs folder.
|
||||
await runProcessWithValidations(
|
||||
<String>[
|
||||
'unzip',
|
||||
'-o',
|
||||
zipDestination,
|
||||
],
|
||||
docsPath,
|
||||
);
|
||||
await runProcessWithValidations(<String>['unzip', '-o', zipDestination], docsPath);
|
||||
|
||||
// Generate versions file.
|
||||
await runProcessWithValidations(
|
||||
<String>['flutter', '--version'],
|
||||
docsPath,
|
||||
);
|
||||
await runProcessWithValidations(<String>['flutter', '--version'], docsPath);
|
||||
final File versionFile = File('version');
|
||||
final String version = versionFile.readAsStringSync();
|
||||
// Recreate footer
|
||||
@@ -84,7 +71,9 @@ Future<String> gitRevision({
|
||||
if (fullLength) {
|
||||
return gitRevision;
|
||||
}
|
||||
return gitRevision.length > kGitRevisionLength ? gitRevision.substring(0, kGitRevisionLength) : gitRevision;
|
||||
return gitRevision.length > kGitRevisionLength
|
||||
? gitRevision.substring(0, kGitRevisionLength)
|
||||
: gitRevision;
|
||||
}
|
||||
|
||||
/// Wrapper function to run a subprocess checking exit code and printing stderr and stdout.
|
||||
@@ -96,8 +85,11 @@ Future<void> runProcessWithValidations(
|
||||
@visibleForTesting ProcessManager processManager = const LocalProcessManager(),
|
||||
bool verbose = true,
|
||||
}) async {
|
||||
final ProcessResult result =
|
||||
processManager.runSync(command, stdoutEncoding: utf8, workingDirectory: workingDirectory);
|
||||
final ProcessResult result = processManager.runSync(
|
||||
command,
|
||||
stdoutEncoding: utf8,
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
if (result.exitCode == 0) {
|
||||
if (verbose) {
|
||||
print('stdout: ${result.stdout}');
|
||||
@@ -123,21 +115,31 @@ Future<String> getBranchName({
|
||||
if (luciBranch != null && luciBranch.trim().isNotEmpty) {
|
||||
return luciBranch.trim();
|
||||
}
|
||||
final ProcessResult gitResult = processManager.runSync(<String>['git', 'status', '-b', '--porcelain']);
|
||||
final ProcessResult gitResult = processManager.runSync(<String>[
|
||||
'git',
|
||||
'status',
|
||||
'-b',
|
||||
'--porcelain',
|
||||
]);
|
||||
if (gitResult.exitCode != 0) {
|
||||
throw 'git status exit with non-zero exit code: ${gitResult.exitCode}';
|
||||
}
|
||||
final RegExpMatch? gitBranchMatch = gitBranchRegexp.firstMatch((gitResult.stdout as String).trim().split('\n').first);
|
||||
final RegExpMatch? gitBranchMatch = gitBranchRegexp.firstMatch(
|
||||
(gitResult.stdout as String).trim().split('\n').first,
|
||||
);
|
||||
return gitBranchMatch == null ? '' : gitBranchMatch.group(1)!.split('...').first;
|
||||
}
|
||||
|
||||
/// Updates the footer of the api documentation with the correct branch and versions.
|
||||
/// [footerPath] is the path to the location of the footer js file and [version] is a
|
||||
/// string with the version calculated by the flutter tool.
|
||||
Future<void> createFooter(File footerFile, String version,
|
||||
{@visibleForTesting String? timestampParam,
|
||||
@visibleForTesting String? branchParam,
|
||||
@visibleForTesting String? revisionParam}) async {
|
||||
Future<void> createFooter(
|
||||
File footerFile,
|
||||
String version, {
|
||||
@visibleForTesting String? timestampParam,
|
||||
@visibleForTesting String? branchParam,
|
||||
@visibleForTesting String? revisionParam,
|
||||
}) async {
|
||||
final String timestamp = timestampParam ?? DateFormat('yyyy-MM-dd HH:mm').format(DateTime.now());
|
||||
final String gitBranch = branchParam ?? await getBranchName();
|
||||
final String revision = revisionParam ?? await gitRevision();
|
||||
|
||||
Reference in New Issue
Block a user