diff options
author | Kenny Cheng <chao.shun.cheng.tw@gmail.com> | 2025-06-02 21:55:04 +0800 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2025-07-01 16:11:50 -0700 |
commit | 82d500eb7aa93f9bff66a4358a08d2ba2d599550 (patch) | |
tree | 60d2003fa946943a13bfb9a96bd88bb60167c57f /hooks.py | |
parent | 21269c3eedc428610a5cab1494b2459a7e939fc7 (diff) | |
download | git-repo-82d500eb7aa93f9bff66a4358a08d2ba2d599550.tar.gz |
sync: support post-sync hook in <repo-hooks>
Add support for a new hook type "post-sync" declared in the manifest using
<repo-hooks>. This allows executing a script automatically after a successful
`repo sync`.
This is useful for initializing developer environments, installing project-wide
Git hooks, generating configs, and other post-sync automation tasks.
Example manifest usage:
<project name="myorg/repo-hooks" path="hooks" revision="main" />
<repo-hooks in-project="myorg/repo-hooks" enabled-list="post-sync">
<hook name="post-sync" />
</repo-hooks>
The hook script must be named `post-sync.py` and located at the root of the
hook project.
The post-sync hook does not block `repo sync`; if the script fails, the sync
still completes successfully with a warning.
Test: Added `post-sync.py` in hook project and verified it runs after `repo sync`
Bug: b/421694721
Change-Id: I69f3158f0fc319d73a85028d6e90fea02c1dc8c8
Signed-off-by: Kenny Cheng <chao.shun.cheng.tw@gmail.com>
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/480581
Reviewed-by: Scott Lee <ddoman@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'hooks.py')
-rw-r--r-- | hooks.py | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -25,6 +25,7 @@ from git_refs import HEAD | |||
25 | # The API we've documented to hook authors. Keep in sync with repo-hooks.md. | 25 | # The API we've documented to hook authors. Keep in sync with repo-hooks.md. |
26 | _API_ARGS = { | 26 | _API_ARGS = { |
27 | "pre-upload": {"project_list", "worktree_list"}, | 27 | "pre-upload": {"project_list", "worktree_list"}, |
28 | "post-sync": {"repo_topdir"}, | ||
28 | } | 29 | } |
29 | 30 | ||
30 | 31 | ||