When you run `repo upload` to upload your local commits to Gerrit, a preupload phase runs. This is used to run linters or local unittests to catch various common errors.
These can be customized on a per-git repo basis. You can have custom scripts execute using the hooks phase, or opt in/out of common checks that are kept in the main upload script.
You can find the main preupload script in the src/repohooks/ directory.
All settings live in the PRESUBMIT.cfg file in the root of the git repo.
You can run arbitrary scripts with the hooks section.
Make sure you send stderr to stdout.
You can list as many/few scripts as you want. Just keep adding a unique number after the "hook" key name.
Since many tests are not specific to a repo, we make them available we enable them on a global basis. You can see the current list by looking at the _DISABLE_FLAGS dict in the pre-upload.py file itself.
When looking to add a new check, you should first consider whether it would benefit more projects than just your own. If so, you should add it to the repohooks/pre-upload.py file itself.
This isn't directly related to repohooks, but you can learn more about COMMIT-QUEUE.ini in the Bypassing tests on a per-project basis page.