summaryrefslogtreecommitdiffstats
path: root/scripts/git-integration/gen-templates.py
blob: e451b53eaf8aea93bf2265fa8f5b69ca05c71b47 (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
#!/usr/bin/python3

import configparser
import os
import shutil
import sys

config = configparser.RawConfigParser()
config.read(os.path.dirname(os.path.realpath(__file__)) + "/../../conf/config")

template_path = config.get('serve', 'template-path')
git_update_hook = config.get('serve', 'git-update-hook')

def die(msg):
    sys.stderr.write("%s\n" % (msg))
    exit(1)

if os.path.exists(template_path):
    shutil.rmtree(template_path)

os.mkdir(template_path)
os.chdir(template_path)
os.mkdir("branches")
os.mkdir("hooks")
os.mkdir("info")
os.symlink(git_update_hook, template_path + 'hooks/update')

with open("description", 'w') as f:
    f.write("Unnamed repository; push to update the description.\n")