Skip to content

[tool] Restore publishability#11745

Open
stuartmorgan-g wants to merge 9 commits into
flutter:mainfrom
stuartmorgan-g:tool-publishability
Open

[tool] Restore publishability#11745
stuartmorgan-g wants to merge 9 commits into
flutter:mainfrom
stuartmorgan-g:tool-publishability

Conversation

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

Restores the repo tooling to a publishable state, so that we can start using it for flutter/core-packages.

I expect fixes will be necessary to make it actually work correctly in that repo, but this gives us a foundation to iterate from where we can actually publish and test changes:

  • Removes publish_to: none
  • Restores the old CHANGELOG, and adds a new entry for the new version.
  • Moves the formatter download cache to the repo root instead of a directory that other repo's wont have
  • Changes the setup to find the repo root by walking up from the current directory until finding something that looks like the repo root, rather than hard-coding a relative path from the invoked script.
  • Adds back some initial documentation about how to use this in another repo. Having two ways of running it was always confusing to explain, so this tries a new approach of demonstrating setting up an alias, and then having all the examples use that alias. We may need to iterate if that proves confusing (to people and/or to AI agents)

Fixes flutter/flutter#185764

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 20, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the repository tooling to support global installation and improves repository root detection by replacing hardcoded paths with a dynamic discovery mechanism. It introduces a centralized .repo_tool_cache for managing external Java and Kotlin formatters and updates the documentation to include setup instructions for both local and global usage. Review feedback highlights the need for robust error handling during formatter downloads, improved repository root detection to accommodate git worktrees, and the correction of syntax errors in the README's shell examples. Additionally, a concern was raised regarding side effects within the cache directory resolution utility.

Comment thread script/tool/README.md
Comment thread script/tool/README.md
Comment thread script/tool/lib/src/common/core.dart
Comment thread script/tool/lib/src/main.dart Outdated
Comment on lines 482 to +483
final http.Response response = await http.get(_javaFormatterUrl);
javaFormatterFile.writeAsBytesSync(response.bodyBytes);
file.writeAsBytesSync(response.bodyBytes);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The HTTP request lacks error handling. If the download fails (e.g., due to a 404 error or network issues), the tool will write the error response body to the JAR file, causing obscure errors when it later attempts to execute it. Verify the status code before writing.

      final http.Response response = await http.get(_javaFormatterUrl);
      if (response.statusCode != 200) {
        print('Failed to download Google Java Format (error ${response.statusCode})');
        throw ToolExit(1);
      }
      file.writeAsBytesSync(response.bodyBytes);

Comment on lines 494 to +495
final http.Response response = await http.get(_kotlinFormatterUrl);
kotlinFormatterFile.writeAsBytesSync(response.bodyBytes);
file.writeAsBytesSync(response.bodyBytes);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The HTTP request lacks error handling. Verify the status code before writing the bytes to the file.

      final http.Response response = await http.get(_kotlinFormatterUrl);
      if (response.statusCode != 200) {
        print('Failed to download ktfmt (error ${response.statusCode})');
        throw ToolExit(1);
      }
      file.writeAsBytesSync(response.bodyBytes);

@github-actions github-actions Bot removed the CICD Run CI/CD label May 20, 2026
@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label May 20, 2026
Copy link
Copy Markdown
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

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

Not sure if I like the alias swap, but I guess it's more readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[packages] Return to publishing repo tools

2 participants