-
Notifications
You must be signed in to change notification settings - Fork 1
/
import-job
executable file
·46 lines (38 loc) · 1.45 KB
/
import-job
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#
# Since there is no fetch hooks, and we don't want to complicate
# this more than necessary, we use throw disk space and cpu at it.
#
# Two stages: a bare copy that we mirror into, and then a separate
# local copy that we push to to get the hooks running as expected.
#
# Time will tell if this is a good idea or not. I don't fancy parsing
# stuff in .git by myself.
#
# Author: Lasse Karstensen <lkarsten@varnish-software.com>, March 2016.
FETCHNAME=tmp.git
BARE=bare.git
if [ ! -d "$FETCHNAME" ]; then
git clone --mirror https://github.com/varnishcache/varnish-cache.git $FETCHNAME
# When testing this, avoid waiting for github over and over again.
#git clone --mirror git@github.com:varnishcache/varnish-cache.git localorig
#git clone --mirror ./localorig $FETCHNAME
fi
GIT_DIR=$FETCHNAME git fetch --quiet --all
if [ ! -d "$BARE" ]; then
git init --bare $BARE
GIT_DIR=$FETCHNAME git remote add local $BARE
# Initial push to avoid heaps of notification messages on reset.
GIT_DIR=$FETCHNAME git push --quiet --mirror local
GIT_DIR=$BARE git config --local --add hooks.mailinglist varnish-commit@varnish-cache.org
# Enable the hook inside the bare repo.
ln -sf ../../hooks/send-email $BARE/hooks/post-receive
fi
# Insert a single fresh commit that should be emailed.
if [ "nox" = "x" ]; then
cd onechange
git push --quiet origin
cd ..
fi
# This should trigger post-receive hooks on the BARE repo.
GIT_DIR=$FETCHNAME git push --quiet --mirror local