aboutsummaryrefslogtreecommitdiff
blob: f33c8fc7f4c4e91a6f11a3ed83623572dddc3734 (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
#!/bin/sh
# based on https://github.com/miracle2k/gitolite-simple-mirror/blob/master/post-receive

# simple gitolite mirroring

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

if [ -z "${GL_REPO}" ]; then
	echo "GL_REPO not set" >&2
	exit 1
fi

targets=$(git config --get gitlab.mirror.url)
[ -z "${targets}" ] && exit 0

[ -z "${GIT_SSH_KEY}" ] && export ~/gitlab-ssh-key
export GIT_SSH=$(dirname "$(readlink -f "$0")")/gitlab-ssh-wrapper

for target in ${targets}; do
	# --force because someone may accidentally push into the mirror
	git push --mirror --force ${target}
done