-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmake_repo.sh
82 lines (62 loc) · 1.79 KB
/
make_repo.sh
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# -*- coding: utf-8 -*-
# vim:ts=4:sw=4:expandtab
#
# Deploy test environment for githooks
#
# This script initializes a remote repository in tmp/remote_repo.git
# and deploys githooks in tmp/remote_repo.git/hooks with its
# configuration files in <remote repo>/hooks/conf.
#
# Also, the script initializes a local repository in tmp/repo and sets
# it to track tmp/remote_repo.git.
#
test_root=`pwd`/tmp
rm -rf $test_root
mkdir $test_root
# Init a remote repo.
mkdir $test_root/remote_repo.git
root_dir=$test_root/remote_repo.git/hooks
conf_dir=$root_dir/conf
hooks_dir=$root_dir/hooks.d
git init --bare $test_root/remote_repo.git
mkdir -p $conf_dir
mkdir -p $hooks_dir
# Deploy githooks.
cp githooks.py $root_dir
cp hooks.d/*.py $hooks_dir
chmod +x $root_dir/githooks.py
chmod +x $hooks_dir/*.py
# Create githooks.ini
cat >$root_dir/githooks.ini <<EOL
[notify]
user_name = %(USER)s
base_url = http://STASH
proj_key = TEST
repo_name = test
smtp_server = aspmx.l.google.com
smtp_port = 25
smtp_from =
[email_mention]
user_name = %(USER)s
base_url = http://STASH
proj_key = TEST
repo_name = test
smtp_server = aspmx.l.google.com
smtp_port = 25
smtp_from =
email_domain = gmail.com
EOL
# Copy hook configuration files.
cp `pwd`/pre-receive.conf.sample $conf_dir/pre-receive.conf
cp `pwd`/post-receive.conf.sample $conf_dir/post-receive.conf
echo '#!/bin/bash' > $root_dir/pre-receive
echo "$root_dir/githooks.py pre-receive.conf < /dev/stdin" >> $root_dir/pre-receive
chmod +x $root_dir/pre-receive
echo '#!/bin/bash' > $root_dir/post-receive
echo "$root_dir/githooks.py post-receive.conf < /dev/stdin" >> $root_dir/post-receive
chmod +x $root_dir/post-receive
# Init a local repo.
mkdir $test_root/repo
git init $test_root/repo
git -C $test_root/repo remote add origin $test_root/remote_repo.git