summaryrefslogtreecommitdiff
path: root/setup-receive-hook
blob: 4fd25b436e35aac3f53f8cb9b19aa64e02925d30 (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
#!/usr/bin/env bash

if [ $# -ne 1 ]; then
    echo "usage: setup-receive-hook <name>"
    exit 1
fi

set -xe

USER="compromyse"

base_dir="$HOME"
repo="${base_dir}/$1"

case $repo in
    *\.git)
	;;
    *)
	repo="${new_repo}.git"
	;;
esac

if [ ! -d "$repo" ]; then
    echo "$repo does not exist"
    exit 1
fi

cd $repo
echo 'git push github -f --mirror' > "$new_repo/hooks/post-receive"
chmod +x "$new_repo/hooks/post-receive"