summaryrefslogtreecommitdiff
path: root/per-service/git-servers/roles/grokmirror/templates/gerrit-ref-updated
blob: cf28173b47cad8926bf972faf3902c66f5656102 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Gerrit's hook system is very different from standard git, so
# minor modifications to the hook are required to make it work.
# Place this file in your gerrit/hooks/ref-updated and modify the
# variables below to make it work for you.

GERRIT_HOME={{gerrit_root}}
GERRIT_GIT={{repo_root}}

GROK_MANIFEST_BIN=/usr/local/bin/grok-manifest
GROK_MANIFEST_LOG=${GERRIT_HOME}/logs/grok-manifest.log
# You'll need to place this where you can serve it with httpd
# Make sure the gerrit process can write to this location
GROK_MANIFEST={{apache_root}}/{{git_host}}/manifest.js.gz

# force all output to log file
exec >>${GROK_MANIFEST_LOG} 2>&1

# gerrit calls us with GIT_DIR set, so we just need to extract the project
# portion (with no leading slashes)
repo=${GIT_DIR#${GERRIT_GIT}/}
echo "$(date): $0 called with $*"
echo "$(date): repo changed: $repo"

cd ${GERRIT_GIT}
{% if grokmirror_master_check_export %}
[ -f ${repo}/git-daemon-export-ok ] || touch ${repo}/git-daemon-export-ok
{% endif %}
${GROK_MANIFEST_BIN}{% if grokmirror_master_check_export %} -c{% endif %} -v \
    -m ${GROK_MANIFEST} -t ${GERRIT_GIT} -n ${repo}
git --git-dir=$GIT_DIR update-server-info