Search code examples
pythonandroidgitrepo

How to implement git hook for Android repo tool


My team is using android repo for the project. I've been facing and issue where I've wanted to write my hook for the repo following the documentation, however the doc's of repo seems to allow only one pre-upload hook - and I'm in need of implementing pre-commit and cant get it to work.

Does anyone ever tried implementing git-hooks for repo and have any tutorials/tips/tricks/guildlines?


Solution

  • Solution 1, config system-wide or global core.hooksPath.

    git config --system core.hooksPath /path/to/githooks
    

    The hooks under /path/to/githooks will be provoked. If you are using Gerrit and Change-Id is required, copy the commit-msg to the path too.

    Solution 2, if you use your own repo repository instead of Google's, you can add and commit the hook scripts under repo/hooks so that the repos created by repo sync will create soft links to .repo/repo/hooks/*. To use your own repo repository, you can change the value of REPO_URL in the repo script used to run repo init. The value is the url of your own repo repository.