[projects/git-slug: 69/170] Move code generating files for slug_watch to hook plugin

glen glen at pld-linux.org
Mon Sep 21 21:44:37 CEST 2015


commit e8a6fe85eb536d80c2e352e88a886bd7ffed5940
Author: Kacper Kornet <draenog at pld-linux.org>
Date:   Thu Dec 15 15:21:35 2011 +0000

    Move code generating files for slug_watch to hook plugin

 post-receive                       | 17 -----------------
 post-receive.python.d/slug_hook.py | 18 ++++++++++++++++++
 2 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/post-receive b/post-receive
index c742246..913847c 100755
--- a/post-receive
+++ b/post-receive
@@ -8,11 +8,6 @@ import tempfile
 import sys
 import subprocess
 
-from git_slug.refsdata import RemoteRefsData
-from git_slug.gitconst import REFREPO, REFFILE
-from git_slug.serverconst import WATCHDIR
-from git_slug.gitrepo import GitRepo
-
 
 data = sys.stdin.readlines()
 
@@ -29,15 +24,3 @@ if (os.path.isdir('hooks/post-receive.d')):
 for pluginfile in glob.glob('hooks/post-receive.python.d/*.py'):
     plugin = imp.load_source(os.path.basename(pluginfile), pluginfile)
     plugin.run(data)
-
-gitrepo = os.environ.get('GL_REPO')
-if gitrepo.startswith('packages/'):
-    gitrepo = gitrepo[len('packages/'):]
-else:
-    sys.exit()
-
-(tfile, name) = tempfile.mkstemp(prefix=gitrepo+'.', dir=WATCHDIR)
-os.write(tfile,(os.getenv('GL_USER')+'\n').encode('utf-8'))
-os.write(tfile,(gitrepo+'\n').encode('utf-8'))
-os.write(tfile,''.join(data).encode('utf-8'))
-os.close(tfile)
diff --git a/post-receive.python.d/slug_hook.py b/post-receive.python.d/slug_hook.py
new file mode 100644
index 0000000..efb6346
--- /dev/null
+++ b/post-receive.python.d/slug_hook.py
@@ -0,0 +1,18 @@
+import os
+import tempfile
+
+from git_slug.serverconst import WATCHDIR
+
+
+def run(data):
+    gitrepo = os.environ.get('GL_REPO')
+    if gitrepo.startswith('packages/'):
+        gitrepo = gitrepo[len('packages/'):]
+    else:
+        return
+
+    (tfile, name) = tempfile.mkstemp(prefix=gitrepo+'.', dir=WATCHDIR)
+    os.write(tfile,(os.getenv('GL_USER')+'\n').encode('utf-8'))
+    os.write(tfile,(gitrepo+'\n').encode('utf-8'))
+    os.write(tfile,''.join(data).encode('utf-8'))
+    os.close(tfile)
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5



More information about the pld-cvs-commit mailing list