aboutsummaryrefslogtreecommitdiff
path: root/local/hooks/repo-specific/laminar
blob: 86787138acffd0fcdd0d4f836b1907fa5b2dcda1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

export LAMINAR_REASON="Push to git repository: '${GL_REPO}'"

name="${GL_REPO}"
name=$(printf '%s\n' "${GL_REPO}" | tr / -)

job_exists() {
    while [ $# -gt 0 ]; do
        laminarc show-jobs | grep -q -E "${1}" || return 1
        shift
    done
}

custom_job=$(gitolite git-config "${GL_REPO}" gitolite-options.laminar.job 2>/dev/null)

if job_exists "^${name}($|-.*)"; then
    laminarc start $(laminar show-jobs | grep -E "^${name}($|-.*)") || exit 1
elif [ -n "${custom_job}" ] && job_exists "${custom_job}"; then
    laminarc start "${custom_job}" || exit 1
else
    exit
fi