aboutsummaryrefslogtreecommitdiff
path: root/local/hooks/repo-specific/push-to-mirror
blob: cbd775693811882ed65c8fefda32f8c39d023577 (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
# Sourced from <https://github.com/miracle2k/gitolite-simple-mirror>

# flush STDIN coming from git, because gitolite's own post-receive.mirrorpush
# script does the same thing
[ -t 0 ] || cat >/dev/null

[ -z "$GL_REPO" ] && die GL_REPO not set

set -- $(git config --get gitolite.mirror.simple)
[ "$#" -gt 0 ] || exit

extra_args=$(git config --get gitolite.mirror.simple.extra-args)

while [ "$#" -gt 0 ]; do
    # Support a REPO variable for wildcard mirrors
    gl_repo_escaped=$(printf '%s\n' "$GL_REPO" | sed 's/\//\\\//g')
    gl_repo_escaped=$(basename "${gl_repo_escaped}")
    target=$(printf '%s\n' "${1}" | sed "s/REPO/${gl_repo_escaped}/g")

    git push --mirror "${target}" ${extra_args} 2>&1 | sed 's/^/[mirror] /'
    shift
done