Skip to content

Add pre-commit hook to verify static analysis passes & format is correct - #11941

Merged
auto-submit[bot] merged 44 commits into
flutter:mainfrom
camsim99:cos_precommit
Jul 8, 2026
Merged

Add pre-commit hook to verify static analysis passes & format is correct#11941
auto-submit[bot] merged 44 commits into
flutter:mainfrom
camsim99:cos_precommit

Conversation

@camsim99

@camsim99camsim99 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Adds a pre-commit hook that you can install to verify that dart analyze --fatal-infos and the package format are correct when you make a call to git commit. Intended to ensure agents commit code that meets are quality standards.

Also makes the following updates the plugins tool:

  • Adds --run-on-staged-packages flag that allows the command to only run on files with staged changes. This flag cannot be run with any other flags that filter packages where the command runs (like --run-on-dirty-packages)
  • Adds optimization to the format tool to avoid invoking native tool chains to format when non-native files are modified

Miscellaneous notes:

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

@flutter-dashboardflutter-dashboardBot added the CICD Run CI/CD label Jun 18, 2026
@github-actionsgithub-actionsBot removed the CICD Run CI/CD label Jun 22, 2026
@flutter-dashboardflutter-dashboardBot added the CICD Run CI/CD label Jun 22, 2026
@camsim99camsim99 added CICD Run CI/CD and removed CICD Run CI/CD labels Jun 22, 2026
@camsim99
camsim99 marked this pull request as ready for review June 22, 2026 17:58

@gemini-code-assistgemini-code-assistBot left a comment

Copy link
Copy Markdown
Contributor

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 introduces a new githooks Dart package to automate pre-commit checks, including formatting and static analysis, for staged files. The package includes an installation script, a pre-commit command runner, and associated unit tests. Review feedback highlights a potential infinite loop on Windows when locating the .git directory, raw ANSI escape sequences being printed without verifying terminal support, the use of loose any version constraints in pubspec.yaml, and redundant dead code in the test mocks.

Comment threadscript/githooks/bin/install_hooks.dart
Comment threadscript/githooks/lib/src/pre_commit_command.dart Outdated
Comment threadscript/githooks/lib/src/pre_commit_command.dart Outdated
Comment threadscript/githooks/lib/src/pre_commit_command.dart Outdated
Comment threadscript/githooks/pubspec.yaml
Comment threadscript/githooks/test/pre_commit_command_test.dart
Comment threadscript/githooks/test/pre_commit_command_test.dart
Comment threadscript/githooks/test/pre_commit_command_test.dart
Comment threadscript/githooks/test/pre_commit_command_test.dart
@camsim99camsim99 removed the CICD Run CI/CD label Jun 22, 2026
@reidbaker

reidbaker commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Would you be willing to file a bug to have me/us investigate why the performance gap was so large.

@github-actionsgithub-actionsBot removed the CICD Run CI/CD label Jul 1, 2026
@camsim99camsim99 added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Jul 1, 2026
@auto-submitauto-submitBot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 1, 2026
@auto-submit

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/packages/11941, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@github-actionsgithub-actionsBot removed the CICD Run CI/CD label Jul 6, 2026
@camsim99camsim99 added the CICD Run CI/CD label Jul 6, 2026
@github-actionsgithub-actionsBot removed the CICD Run CI/CD label Jul 7, 2026
@camsim99camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 7, 2026
@auto-submitauto-submitBot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 7, 2026
@auto-submit

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/packages/11941, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@camsim99camsim99 added the CICD Run CI/CD label Jul 7, 2026
@github-actionsgithub-actionsBot removed the CICD Run CI/CD label Jul 7, 2026
@camsim99camsim99 added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Jul 7, 2026
@auto-submit
auto-submitBot merged commit 71ddd07 into flutter:mainJul 8, 2026
13 checks passed
kalyujniy pushed a commit to brickit-app/camera that referenced this pull request Jul 8, 2026
…ect (flutter#11941)
Adds a pre-commit hook that you can install to verify that `dart analyze --fatal-infos` and the package format are correct when you make a call to `git commit`. Intended to ensure agents commit code that meets are quality standards.
Also makes the following updates the plugins tool:
- Adds `--run-on-staged-packages` flag that allows the command to only run on files with staged changes. This flag cannot be run with any other flags that filter packages where the command runs (like `--run-on-dirty-packages`)
- Adds optimization to the format tool to avoid invoking native tool chains to format when non-native files are modified
Miscellaneous notes:
- `script/githooks/bin/install_hooks.dart` is the script to install the hook that devs would need to run to use it.
- I modeled the new `githooks` directory like https://github.com/flutter/flutter/tree/master/engine/src/flutter/tools/githooks to make it easier for folks to add new hooks
## Pre-Review Checklist
**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Renzo-Olivares pushed a commit to mvincentong/flutter that referenced this pull request Jul 9, 2026
…r#189194)
flutter/packages@52d84d6...20928d5
2026-07-09 44525804+sailendrabathi@users.noreply.github.com
[video_player_android] Implement backBufferDurationMs in ExoPlayer
(flutter/packages#12124)
2026-07-09 bolling.ludwig@gmail.com [camera_platform_interface] Make
setJpegImageQuality default a no-op (flutter/packages#12123)
2026-07-09 36081049+anirudhsharma392@users.noreply.github.com
[local_auth] Clarify getAvailableBiometrics documentation regarding iOS
permissions (flutter/packages#11901)
2026-07-09 stuartmorgan@google.com [ci] Add a third web Dart unit test
shard (2/2) (flutter/packages#12150)
2026-07-08 stuartmorgan@google.com [ci] Add a third web Dart unit test
shard (1/2) (flutter/packages#12138)
2026-07-08 43054281+camsim99@users.noreply.github.com Add pre-commit
hook to verify static analysis passes & format is correct
(flutter/packages#11941)
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.
To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose
To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622
Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmitMerge PR when tree becomes green via auto submit AppCICDRun CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@camsim99@reidbaker