summaryrefslogtreecommitdiffstats
path: root/scripts/git-integration/gen-templates.py
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2015-01-08 19:28:34 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2015-01-11 18:44:01 +0100
commit4dbd562b8e5bf8d44a7a19b8e248b2b0e0295eb2 (patch)
tree54904534cca89bb06074799fdb16776534f6201d /scripts/git-integration/gen-templates.py
parentcb661cd971b7a219c33e24875d23afafc6a48334 (diff)
downloadaur-4dbd562b8e5bf8d44a7a19b8e248b2b0e0295eb2.tar.gz
aur-4dbd562b8e5bf8d44a7a19b8e248b2b0e0295eb2.tar.xz
Use custom templates for Git repositories
Do not waste disk space by copying dozens of unneeded sample hooks. Use a custom template directory that only includes the git-update hook. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'scripts/git-integration/gen-templates.py')
-rwxr-xr-xscripts/git-integration/gen-templates.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/git-integration/gen-templates.py b/scripts/git-integration/gen-templates.py
new file mode 100755
index 00000000..e451b53e
--- /dev/null
+++ b/scripts/git-integration/gen-templates.py
@@ -0,0 +1,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")