diff options
author | Ted Pudlik <tpudlik@google.com> | 2022-05-04 17:35:04 +0000 |
---|---|---|
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-04 18:11:31 +0000 |
commit | 0e2b07d11bb2ecdc78be038e46a0baff2a0cc96e (patch) | |
tree | 726d03e7cb7c31e7a9342e740494c8d6d384b257 /pw_presubmit | |
parent | e2070c01dfcf54c6b514d10e508cba4bb85fe8b5 (diff) | |
download | pigweed-0e2b07d11bb2ecdc78be038e46a0baff2a0cc96e.tar.gz |
pw_presubmit: Document install_hook
Also provide some advice on what's suitable for use as a git pre-push
hook.
Change-Id: I1c7c05bb33b6841cdc994c6b24fa905cf6487920
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/93602
Pigweed-Auto-Submit: Ted Pudlik <tpudlik@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Diffstat (limited to 'pw_presubmit')
-rw-r--r-- | pw_presubmit/docs.rst | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pw_presubmit/docs.rst b/pw_presubmit/docs.rst index 899f29e98..c99f4964b 100644 --- a/pw_presubmit/docs.rst +++ b/pw_presubmit/docs.rst @@ -156,6 +156,24 @@ pw_presubmit .. _example-script: + +Git hook +-------- +You can run a presubmit program or step as a `git hook +<https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks>`_ using +``pw_presubmit.install_hook``. This can be used to run certain presubmit +checks before a change is pushed to a remote. + +We strongly recommend that you only run fast (< 15 seconds) and trivial checks +as push hooks, and perform slower or more complex ones in CI. This is because, + +* Running slow checks in the push hook will force you to wait longer for + ``git push`` to complete, and +* If your change fails one of the checks at this stage, it will not yet be + uploaded to the remote, so you'll have a harder time debugging any failures + (sharing the change with your colleagues, linking to it from an issue + tracker, etc). + Example ======= A simple example presubmit check script follows. This can be copied-and-pasted |