| 1 |
#!/bin/bash |
| 2 |
# Gerrit's hook system is very different from standard git, so |
| 3 |
# minor modifications to the hook are required to make it work. |
| 4 |
# Place this file in your gerrit/hooks/ref-updated and modify the |
| 5 |
# variables below to make it work for you. |
| 6 |
|
| 7 |
GERRIT_HOME=/var/lib/gerrit |
| 8 |
GERRIT_GIT=/srv/gerrit/git |
| 9 |
|
| 10 |
GROK_MANIFEST_BIN=/usr/bin/grok-manifest |
| 11 |
GROK_MANIFEST_LOG=${GERRIT_HOME}/logs/grok-manifest.log |
| 12 |
# You'll need to place this where you can serve it with httpd |
| 13 |
# Make sure the gerrit process can write to this location |
| 14 |
GROK_MANIFEST=/var/www/html/grokmirror/manifest.js.gz |
| 15 |
|
| 16 |
# Yank out the project out of the passed params |
| 17 |
args=$(getopt -l "project:" -- "$@") |
| 18 |
|
| 19 |
eval set -- "$args" |
| 20 |
while [ $# -ge 1 ]; do |
| 21 |
case "$1" in |
| 22 |
--) |
| 23 |
# No more options left. |
| 24 |
shift |
| 25 |
break |
| 26 |
;; |
| 27 |
--project) |
| 28 |
project="$2" |
| 29 |
shift |
| 30 |
;; |
| 31 |
esac |
| 32 |
shift |
| 33 |
done |
| 34 |
|
| 35 |
${GROK_MANIFEST_BIN} -y -w -l ${GROK_MANIFEST_LOG} \ |
| 36 |
-m ${GROK_MANIFEST} \ |
| 37 |
-t ${GERRIT_GIT} \ |
| 38 |
-n "${GERRIT_GIT}/${project}.git" |